lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20191101093803.4c10c04a@hermes.lan>
Date:   Fri, 1 Nov 2019 09:38:03 -0700
From:   Stephen Hemminger <stephen@...workplumber.org>
To:     Michał Łyszczek <michal.lyszczek@...c.pl>
Cc:     netdev@...r.kernel.org
Subject: Re: [PATCH v2 iproute2] libnetlink.c, ss.c: properly handle fread()
 errors

On Tue, 29 Oct 2019 12:13:11 +0100
Michał Łyszczek <michal.lyszczek@...c.pl> wrote:

> fread(3) returns size_t data type which is unsigned, thus check
> `if (fread(...) < 0)' is always false. To check if fread(3) has
> failed, user should check error indicator with ferror(3).
> 
> This commit also changes read logic a little bit by being less
> forgiving for errors. Previous logic was checking if fread(3)
> read *at least* required ammount of data, now code checks if
> fread(3) read *exactly* expected ammount of data. This makes
> sense because code parses very specific binary file, and reading
> even 1 less/more byte than expected, will later corrupt data anyway.
> 
> Signed-off-by: Michał Łyszczek <michal.lyszczek@...c.pl>
> 
> ---
> v1 -> v2: fread(3) can also return error on truncated reads and
>             not only on 0bytes read (suggested by Stephen Hemminger)
> 

Thanks, applied.

Isn't error handling messy.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ