Commit 336bd586 authored by Dag Haavi Finstad's avatar Dag Haavi Finstad

Fix WS_Printf off by one error/truncation handling.

parent 5659c4d0
......@@ -175,11 +175,12 @@ WS_Printf(struct ws *ws, const char *fmt, ...)
p = ws->f;
va_start(ap, fmt);
v = vsnprintf(p, u, fmt, ap);
if (v > u) {
va_end(ap);
if (v >= u) {
WS_Release(ws, 0);
p = NULL;
} else {
WS_Release(ws, v);
WS_Release(ws, v + 1);
}
return (p);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment