mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-02 13:20:51 +00:00
survive to width.precision screw ups in %s
This commit is contained in:
1 parent
b766c65615
commit
8eceacc0d3
3 files changed
+17
-2
No files matched your search
+6
-1
@@ -2968,7 +2968,12 @@ size_t mg_vxprintf(void (*out)(char, void *), void *param, const char *fmt,
|
||||
n++;
|
||||
} else if (c == 's') {
|
||||
char *p = va_arg(*ap, char *);
|
||||
if (pr == ~0U) pr = p == NULL ? 0 : strlen(p);
|
||||
if (p != NULL && pr != ~0U) {
|
||||
for (j = 0; j < pr && p[j] != '\0'; j++) ; // portable strnlen()
|
||||
pr = j;
|
||||
} else {
|
||||
pr = p == NULL ? 0 : strlen(p);
|
||||
}
|
||||
for (j = 0; !minus && pr < w && j + pr < w; j++)
|
||||
n += scpy(out, param, &pad, 1);
|
||||
n += scpy(out, param, p, pr);
|
||||
|
||||
Reference in new issue
Block a user