projects
/
musl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
de543b0
)
don't crash on null strings in printf
author
Rich Felker
<dalias@aerifal.cx>
Thu, 29 Sep 2011 02:07:58 +0000
(22:07 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Thu, 29 Sep 2011 02:07:58 +0000
(22:07 -0400)
passing null pointer for %s is UB but lots of broken programs do it anyway
src/stdio/vfprintf.c
patch
|
blob
|
history
diff --git
a/src/stdio/vfprintf.c
b/src/stdio/vfprintf.c
index
4c990e5
..
b5001ff
100644
(file)
--- a/
src/stdio/vfprintf.c
+++ b/
src/stdio/vfprintf.c
@@
-584,7
+584,7
@@
static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
case 'm':
if (1) a = strerror(errno); else
case 's':
case 'm':
if (1) a = strerror(errno); else
case 's':
- a = arg.p;
+ a = arg.p
? arg.p : "(null)"
;
z = memchr(a, 0, p);
if (!z) z=a+p;
else p=z-a;
z = memchr(a, 0, p);
if (!z) z=a+p;
else p=z-a;