-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/string/: Redesign stpecpy() and stpeprintf()
Make them report truncation via errno and NULL. Instead of having three possible returns (a pointer to the NUL byte, the end of the array, or NULL), reduce it to two possible ones: one for success, and one for error. Use errno, which is a common way to signal the specific error, and thus treat truncation as any other error. This simplifies error handling after these calls. Also, if one misuses a pointer after truncation, the results are better if the pointer is NULL: the program will easily abort. If we returned 'end', the program could more easily produce a buffer overrun. Suggested-by: Douglas McIlroy <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
- Loading branch information
1 parent
8a5852a
commit 62d3f05
Showing
2 changed files
with
23 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters