Austin Group Defect Tracker

Aardvark Mark IV


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

- Relationships

-  Notes
(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 [^]

- Issue History
Date Modified Username Field Change
2023-05-10 06:29 Florian Weimer New Issue
2023-05-10 06:29 Florian Weimer Name => Florian Weimer
2023-05-10 06:29 Florian Weimer Organization => Red Hat
2023-05-10 06:29 Florian Weimer User Reference => swbz#178
2023-05-10 06:29 Florian Weimer Section => strlcat
2023-05-10 06:29 Florian Weimer Page Number => unknown
2023-05-10 06:29 Florian Weimer Line Number => unknown
2023-05-10 06:30 Florian Weimer Note Added: 0006277
2023-05-10 06:31 Florian Weimer Issue Monitored: Florian Weimer
2023-05-23 14:01 geoffclare Project 1003.1(2013)/Issue7+TC1 => Issue 8 drafts
2023-05-23 14:03 geoffclare Page Number unknown => 2133
2023-05-23 14:03 geoffclare Line Number unknown => 69861
2023-05-23 14:03 geoffclare version => Draft 3


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker