mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
strftime: fix breakage in last change (uninitialized pointer access)
commit f47a5d400b
overlooked that
strtoul was responsible for setting p to a const-laundered copy of the
format string pointer f, even in the case where there was no number to
parse. by making the call conditional on isdigit, that copy was lost.
the logic here is a mess and should be cleaned up, but for now, this
seems to be the least invasive change that undoes the breakage.
This commit is contained in:
parent
cf91e9b393
commit
4a16ddf53e
1 changed files with 6 additions and 1 deletions
|
@ -234,7 +234,12 @@ size_t __strftime_l(char *restrict s, size_t n, const char *restrict f, const st
|
|||
pad = 0;
|
||||
if (*f == '-' || *f == '_' || *f == '0') pad = *f++;
|
||||
if ((plus = (*f == '+'))) f++;
|
||||
width = isdigit(*f) ? strtoul(f, &p, 10) : 0;
|
||||
if (isdigit(*f)) {
|
||||
width = strtoul(f, &p, 10);
|
||||
} else {
|
||||
width = 0;
|
||||
p = (void *)f;
|
||||
}
|
||||
if (*p == 'C' || *p == 'F' || *p == 'G' || *p == 'Y') {
|
||||
if (!width && p!=f) width = 1;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue