Viewing Issue Simple Details
[ Jump to Notes ]
|
[ Issue History ]
[ Print ]
|
ID |
Category |
Severity |
Type |
Date Submitted |
Last Update |
0001397 |
[1003.1(2008)/Issue 7] System Interfaces |
Objection |
Error |
2020-08-30 20:53 |
2021-02-08 16:12 |
|
Reporter |
sebor |
View Status |
public |
|
Assigned To |
ajosey |
Priority |
normal |
Resolution |
Duplicate |
|
Status |
Closed |
|
|
|
|
Name |
Martin Sebor |
Organization |
|
User Reference |
|
Section |
strndup |
Page Number |
unknown |
Line Number |
unknown |
Interp Status |
--- |
Final Accepted Text |
|
|
Summary |
0001397: strndup incorrectly implies argument must be a string |
Description |
Because 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 Action |
Correct 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(), ... |
Tags |
No tags attached. |
|
Attached Files |
|
|