[BUG] A string format defect in Nginx 0.8.48
Gary Hu
yuejun24.hu at gmail.com
Tue Aug 10 08:07:30 MSD 2010
Hi All,
I found a defect in function "ngx_vslprintf”which doesn't support right
alignment format of a string, such as "%40s", as purported in the comments
right above the function "ngx_sprintf" in file "src/core/ngx_string.c".
The following is my suggested fix in function "ngx_vslprintf ":
......
case 's':
p = va_arg(args, u_char *);
//
// Added by Gary Hu
//
size_t sublen;
size_t padlen;
sublen = ngx_strlen(p);
/* Add padding whitespaces to the output buffer to achieve
right alignment*/
if (width > 0 && width > sublen)
{
padlen = ngx_min(((size_t) (last - buf)), width - sublen
);
ngx_memset(buf, ' ', padlen);
buf += padlen;
}
//
// End added by Gary Hu
//
if (slen == (size_t) -1) {
while (*p && buf < last) {
*buf++ = *p++;
}
} else {
len = ngx_min(((size_t) (last - buf)), slen);
buf = ngx_cpymem(buf, p, len);
}
fmt++;
continue;
case 'O':
......
Best Regards,
Gary Hu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx-devel/attachments/20100810/dd383582/attachment-0001.html>
More information about the nginx-devel
mailing list