All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Michał Łyszczek" <michal.lyszczek@bofc.pl>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] libnetlink.c, ss.c: properly handle fread() error
Date: Mon, 28 Oct 2019 21:21:28 -0700	[thread overview]
Message-ID: <20191028212128.1b8c5054@hermes.lan> (raw)
In-Reply-To: <20191024212001.7020-1-michal.lyszczek@bofc.pl>

On Thu, 24 Oct 2019 23:20:01 +0200
Michał Łyszczek <michal.lyszczek@bofc.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 if return is 0 and then check error
> indicator with ferror(3).
> 
> Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>

You did find something that probably has been broken for a long time.

First off, not sure why libnetlink is using fread here anyway.
It adds another copy to all I/O which can matter with 1M routes.

Also the man page for fread() implies that truncated reads (not
just zero) can happen on error. Better to check that full read was
completed or at least a valid netlink header?

  reply	other threads:[~2019-10-29  4:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 21:20 [PATCH iproute2] libnetlink.c, ss.c: properly handle fread() error Michał Łyszczek
2019-10-29  4:21 ` Stephen Hemminger [this message]
2019-10-29 11:13   ` [PATCH v2 iproute2] libnetlink.c, ss.c: properly handle fread() errors Michał Łyszczek
2019-11-01 16:38     ` Stephen Hemminger
2019-10-29 11:35   ` [PATCH iproute2] libnetlink.c, ss.c: properly handle fread() error michal.lyszczek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191028212128.1b8c5054@hermes.lan \
    --to=stephen@networkplumber.org \
    --cc=michal.lyszczek@bofc.pl \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.