Bug 193235 - basename(3) potentially failing with ENOMEM, etc is not documented
Summary: basename(3) potentially failing with ENOMEM, etc is not documented
Status: New
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-02 01:18 UTC by Enji Cooper
Modified: 2018-10-31 05:47 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer 2014-09-02 01:18:15 UTC
basename(3) creates a static buffer for storing paths. This libcall can fail if malloc fails however, and this potential failure isn't documented in the manage:

68 char *
69 basename(const char *path)
70 {
71         static char *bname = NULL;
72 
73         if (bname == NULL) {
74                 bname = (char *)malloc(MAXPATHLEN);
75                 if (bname == NULL)
76                         return (NULL);
77         }
Comment 1 Yuri Pankov freebsd_committer 2018-10-31 05:47:08 UTC
Note that basename(3) was reimplemented in FreeBSD 12, and correctly doesn't have any errors defined, so this only applies to 11.2/11-STABLE at the moment.