mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: "Érico Nogueira" <ericonr@disroot.org>
Cc: musl@lists.openwall.com, Alyssa Ross <hi@alyssa.is>
Subject: Re: [musl] [PATCH musl 3/3] mntent: fix parsing lines with optional fields
Date: Fri, 27 Aug 2021 12:59:18 -0400	[thread overview]
Message-ID: <20210827165916.GX13220@brightrain.aerifal.cx> (raw)
In-Reply-To: <20210827164928.GW13220@brightrain.aerifal.cx>

On Fri, Aug 27, 2021 at 12:49:28PM -0400, Rich Felker wrote:
> On Fri, Aug 27, 2021 at 12:27:36PM -0300, Érico Nogueira wrote:
> > Try avoiding unrelated changes in the commit, since they can introduce
> > subtle bugs. In this case, making n size_t[] instead of int[] will lead
> > to pointer type mismatches in the sscanf call, given that %n expects an
> > int*.
> > 
> > I don't know if *scanf guarantees it won't read enough to go past
> 
> For *scanf in general there is no such guarantee; not even size_t is
> safe for fscanf. However, here you have sscanf and the number is
> bounded by strlen(linebuf).
> 
> > INT_MAX, though, so making a change to size_t[] and using %ln might make
> > sense. Deferring to someone else to answer that.
> 
> The conversion specifier for size_t is %zu not %ln. Since in theory
> strlen(linebuf) could be more than INT_MAX, I think this change should
> be made, but it should be a separate bugfix.

Sorry, that should be '%zn'. '%zu' of course is for reading an integer
of type size_t not counting the bytes processed.

      reply	other threads:[~2021-08-27 16:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-21  8:54 [musl] [PATCH 0/3] " Alyssa Ross
2021-08-21  8:54 ` [musl] [PATCH libc-test 1/3] functional: add mntent test Alyssa Ross
2021-08-21  8:54 ` [musl] [PATCH libc-test 2/3] functional: add mntent test for single-field line Alyssa Ross
2021-08-21  8:54 ` [musl] [PATCH musl 3/3] mntent: fix parsing lines with optional fields Alyssa Ross
2021-08-27 15:27   ` Érico Nogueira
2021-08-27 16:49     ` Rich Felker
2021-08-27 16:59       ` Rich Felker [this message]

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=20210827165916.GX13220@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=ericonr@disroot.org \
    --cc=hi@alyssa.is \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).