Welcome! Log In Create A New Profile

Advanced

[BUG] A string format defect in Nginx 0.8.48

Gary Hu
August 10, 2010 12:08AM
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
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[BUG] A string format defect in Nginx 0.8.48

Gary Hu 2339 August 10, 2010 12:08AM

Re: [BUG] A string format defect in Nginx 0.8.48

Maxim Dounin 962 August 10, 2010 05:08AM

Re: [BUG] A string format defect in Nginx 0.8.48

Gary Hu 1368 August 10, 2010 07:06AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 322
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready