Anonymous | Login | 2023-06-11 01:55 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||||||
ID | Category | Severity | Type | Date Submitted | Last Update | |||||||
0001726 | [Issue 8 drafts] System Interfaces | Editorial | Clarification Requested | 2023-05-10 06:29 | 2023-05-23 14:03 | |||||||
Reporter | Florian Weimer | View Status | public | |||||||||
Assigned To | ||||||||||||
Priority | normal | Resolution | Open | |||||||||
Status | New | Product Version | Draft 3 | |||||||||
Name | Florian Weimer | |||||||||||
Organization | Red Hat | |||||||||||
User Reference | swbz#178 | |||||||||||
Section | strlcat | |||||||||||
Page Number | 2133 | |||||||||||
Line Number | 69861 | |||||||||||
Final Accepted Text | ||||||||||||
Summary | 0001726: strlcat specification is ambiguous regarding return value | |||||||||||
Description |
A glibc developer tried to implement a hand-written assembler version of strlcat based on the POSIX specification and the OpenBSD manual page, and they were surprised when our test suite flagged their implementation as broken. Effectively, we test that strlcat (buf, src, 0) is equivalent to: strlen (src) But the specification can be easily read as saying that it should be strlen (buf) + strlen (src) i.e., that it does not matter whether the original contents of the destination buffer contains null bytes or not. |
|||||||||||
Desired Action |
Existing implementations use the buffer size as a bound for the length of the original buffer contents. This is documented fairly explicitly in the Solaris manual page: “The function returns min{dstsize, strlen(dst)} + strlen(src).” <https://docs.oracle.com/cd/E36784_01/html/E36874/strlcat-3c.html> [^] I think the POSIX version should be change so that it is clear that it does not mandate a different behavior. Either it should say explicitly that the return value of strlcat is strnlen(dst, dstsize) + strlen(src) or that strlcat behavior is undefined if there is no null byte among the first dstsize bytes in the buffer at buf. |
|||||||||||
Tags | No tags attached. | |||||||||||
Attached Files | ||||||||||||
|
![]() |
|
(0006277) Florian Weimer (reporter) 2023-05-10 06:30 |
Sorry, the <> markup garbled the link, it should be: https://docs.oracle.com/cd/E36784_01/html/E36874/strlcat-3c.html [^] |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |