This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, I'm curious about the behavior of swprintf function in the case n is lower than input length. POSIX says that the 'terminating zero shall be always added' and (in 'return code') 'if n or more characters were requested to write, swprintf should return -1'. glibc's swprintf seems to not add the zero in this case, so for wchar_t input[7] = L"6chars\0" wchar_t buffer[10] = L"---------\0" swprintf(buffer, 5, L"%ls", input); you will get buffer = "6cha-----\0", which is 4 characters copied and missing null. -1 returned. Is this behavior a bug, or is it intentional (aka: n < input length is an error, thus the side effect on the buffers is not defined)? I've already traced this to the source and can provide a patch, but I'm not sure if that behavior is really a bug. Petr
Attachment:
signature.asc
Description: This is a digitally signed message part
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |