[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-man
Subject:    Re: [patch] strtok.3 add note about glibc-2.25+ segfault for call like strtok_r(NULL,"|",NULL)
From:       Wilco Dijkstra <Wilco.Dijkstra () arm ! com>
Date:       2020-04-25 16:54:45
Message-ID: DB8PR08MB50360CF57C6AD1A2C7EEB43A83D10 () DB8PR08MB5036 ! eurprd08 ! prod ! outlook ! com
[Download RAW message or body]

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.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic