mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Pascal Cuoq <cuoq@trust-in-soft.com>
To: "musl@lists.openwall.com" <musl@lists.openwall.com>
Subject: Re: [musl] Invalid pointer subtractions in __shlim and __shgetc
Date: Thu, 23 Apr 2020 11:34:26 +0000	[thread overview]
Message-ID: <1587641710830.20636@trust-in-soft.com> (raw)
In-Reply-To: <20200417175651.GK11469@brightrain.aerifal.cx>

Hello again,

Rich Felker <dalias@libc.org> wrote:
> I think this patch may result in wrong error behavior on a trivial
> scanf that doesn't try to read anything. Instead it should be:
>
>        if (!f->rpos) __toread(f);
>        if (!f->rpos) goto input_fail;
>
> so that the error path is taken only on failure to enter read mode,
> not on EOF.

This has indeed fixed the invalid comparisons that were observed
from the tests I mentioned earlier, but a different test still has
the same problem.

As of commit 33338eb, the function wcstox does:
        f.rpos = f.rend = 0;
        f.buf = buf + 4;

(https://git.musl-libc.org/cgit/musl/tree/src/stdlib/wcstol.c?id=33338ebc853d37c80f0f236cc7a92cb0acc6aace#n38 )

It then passes the address of this f to shlim (line 45), causing the same invalid pointer subtraction f->buf - f->rpos that has already been discussed in this thread.

Best regards,

Pascal

  reply	other threads:[~2020-04-23 11:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-17 15:56 Pascal Cuoq
2020-04-17 16:13 ` Rich Felker
2020-04-17 16:48   ` Rich Felker
2020-04-17 17:56     ` Rich Felker
2020-04-23 11:34       ` Pascal Cuoq [this message]
2020-04-23 16:14         ` Rich Felker
2020-04-24  9:40           ` Pascal Cuoq
2020-04-24 14:12             ` Rich Felker

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=1587641710830.20636@trust-in-soft.com \
    --to=cuoq@trust-in-soft.com \
    --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).