Opened 8 years ago

Closed 8 years ago

#866 closed defect (invalid)

ngx_pstrdup() and ngx_copy() problems

Reported by: Sem-ym@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.9.x
Keywords: ngx_copy, ngx_pstrdup, stings Cc: sem33@…
uname -a: any
nginx -V: any



It looks like strings are supposed to finish with '\0' char to be compatible with C strings. So ngx_pstrdup() must allocate and copy len+1, not just len.

ngx_copy() returns different values for different preprocessor conditions.

I don't know how to attach a file here, so patch could be found here:

Attachments (1)

ngx_strings.patch (838 bytes ) - added by Sem-ym@… 8 years ago.

Download all attachments as: .zip

Change History (2)

by Sem-ym@…, 8 years ago

Attachment: ngx_strings.patch added


comment:1 by Maxim Dounin, 8 years ago

Resolution: invalid
Status: newclosed

No, your assumptions are wrong. Strings in nginx are not expected to be null-terminated in general. The ngx_pstrdup() function is expected to duplicate the string passed, exactly, and this is what it currently does. The change to ngx_copy() is also wrong, you've missed dst++ in the loop.

Please also see

Note: See TracTickets for help on using tickets.