linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: Marcin Stolarek <stolarek.marcin@gmail.com>,
	"mtk.manpages@gmail.com" <mtk.manpages@gmail.com>
Cc: linux-man <linux-man@vger.kernel.org>
Subject: Re: [patch] strtok.3 add note about glibc-2.25+ segfault for call like strtok_r(NULL,"|",NULL)
Date: Sat, 25 Apr 2020 16:54:45 +0000	[thread overview]
Message-ID: <DB8PR08MB50360CF57C6AD1A2C7EEB43A83D10@DB8PR08MB5036.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <CAC8K6BP1TFVjQRxs873FUCBNdOVNAkb+d1exd41Q_CTUvCjnSw@mail.gmail.com>

Hi,

> It worked fine prior to 2.25, since it's a change I thoight it may be nice to document that this set
> of arguments will segfault and has to be avoided by calling app itself.

Did it ever? Even much older versions have always accessed *save_ptr with a NULL input, so a crash
is guaranteed. And *s is also always accessed, so it had better never be NULL. Eg. this is what it did
back in 2007 ([1]):

  if (s == NULL)
    s = *save_ptr;  // crash here

  /* Scan leading delimiters.  */
  s += strspn (s, delim);
  if (*s == '\0')
    {
      *save_ptr = s;
      return NULL;
    }

Cheers,
Wilco

[1] https://github.com/bminor/glibc/blob/0ecb606cb6cf65de1d9fc8a919bceb4be476c602/string/strtok_r.c

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

      parent reply	other threads:[~2020-04-25 16:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-25 12:52 [patch] strtok.3 add note about glibc-2.25+ segfault for call like strtok_r(NULL,"|",NULL) Marcin Stolarek
2020-04-25 16:15 ` Michael Kerrisk (man-pages)
     [not found]   ` <CAC8K6BP1TFVjQRxs873FUCBNdOVNAkb+d1exd41Q_CTUvCjnSw@mail.gmail.com>
2020-04-25 16:54     ` Wilco Dijkstra [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=DB8PR08MB50360CF57C6AD1A2C7EEB43A83D10@DB8PR08MB5036.eurprd08.prod.outlook.com \
    --to=wilco.dijkstra@arm.com \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=stolarek.marcin@gmail.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.
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).