summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-06-22 17:23:45 -0400
committerRich Felker <dalias@aerifal.cx>2013-06-22 17:23:45 -0400
commitef5507867b59d19f21437970e87b5d0415c07b2e (patch)
treec08887f82e0896740a636af337242d0c3ba2f4d9
parentc20804500deebaabc56f383d48dd1ac77dce8349 (diff)
downloadmusl-ef5507867b59d19f21437970e87b5d0415c07b2e.tar.gz
fix scanf %c conversion wrongly storing a terminating null byte
this seems to have been a regression from the refactoring which added the 'm' modifier.
-rw-r--r--src/stdio/vfscanf.c6
-rw-r--r--src/stdio/vfwscanf.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c
index 6bea6ad8..bb928480 100644
--- a/src/stdio/vfscanf.c
+++ b/src/stdio/vfscanf.c
@@ -265,8 +265,10 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap)
if (size == SIZE_l) *(wchar_t **)dest = wcs;
else *(char **)dest = s;
}
- if (wcs) wcs[i] = 0;
- if (s) s[i] = 0;
+ if (t != 'c') {
+ if (wcs) wcs[i] = 0;
+ if (s) s[i] = 0;
+ }
break;
case 'p':
case 'X':
diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c
index b1eb7939..760864ff 100644
--- a/src/stdio/vfwscanf.c
+++ b/src/stdio/vfwscanf.c
@@ -281,8 +281,10 @@ int vfwscanf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap)
if (size == SIZE_l) *(wchar_t **)dest = wcs;
else *(char **)dest = s;
}
- if (wcs) wcs[i] = 0;
- if (s) s[i] = 0;
+ if (t != 'c') {
+ if (wcs) wcs[i] = 0;
+ if (s) s[i] = 0;
+ }
break;
case 'd': case 'i': case 'o': case 'u': case 'x':