View Issue Details

IDProjectCategoryView StatusLast Update
00013971003.1(2008)/Issue 7System Interfacespublic2021-02-08 16:12
Reportersebor Assigned Toajosey  
PrioritynormalSeverityObjectionTypeError
Status ClosedResolutionDuplicate 
NameMartin Sebor
Organization
User Reference
Sectionstrndup
Page Numberunknown
Line Numberunknown
Interp Status---
Final Accepted Text
Summary0001397: strndup incorrectly implies argument must be a string
DescriptionBecause it doesn't make use of the term array, and because it refers to "the length of s," the specification for strndup() suggests the s argument is required to be a nul-terminated string rather than an arbitrary array of characters. However, the canonical implementation of the function is to call strnlen() with the size argument as the bound to determine the number of characters to copy (see also APPLICATION USAGE). Thus the function accepts as the first argument an array that need not be a nul-terminated string.
Desired ActionCorrect strndup() to make it explicit that s doesn't have to point to a nul-terminated string, e.g., like so:

The strndup() function shall be equivalent to the strdup() function, duplicating the <ins>smaller of the number of bytes in the array to which s points, not including any terminating NUL character, or the value of the maxlen argument, </ins><del>provided s</del> in a new block of memory allocated as if by using malloc(), ...
TagsNo tags attached.

Relationships

duplicate of 0001019 Closed 1003.1(2013)/Issue7+TC1 strndup shouldn't require source array to be null-terminated 

Activities

geoffclare

2020-09-01 08:31

manager   bugnote:0004963

This should be closed as a duplicate of bug 0001019.

Issue History

Date Modified Username Field Change
2020-08-30 20:53 sebor New Issue
2020-08-30 20:53 sebor Status New => Under Review
2020-08-30 20:53 sebor Assigned To => ajosey
2020-08-30 20:53 sebor Name => Martin Sebor
2020-08-30 20:53 sebor Section => strndup
2020-08-30 20:53 sebor Page Number => unknown
2020-08-30 20:53 sebor Line Number => unknown
2020-09-01 08:31 geoffclare Note Added: 0004963
2020-09-01 08:31 geoffclare Relationship added duplicate of 0001019
2021-02-08 16:12 geoffclare Interp Status => ---
2021-02-08 16:12 geoffclare Status Under Review => Closed
2021-02-08 16:12 geoffclare Resolution Open => Duplicate