Bug 193235

Summary: basename(3) potentially failing with ENOMEM, etc is not documented
Product: Documentation Reporter: Enji Cooper <ngie>
Component: Manual PagesAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Overcome By Events    
Severity: Affects Some People CC: doc, markj, yuripv
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   

Description Enji Cooper freebsd_committer freebsd_triage 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 freebsd_triage 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.
Comment 2 Ridge_Sylvester 2024-01-18 19:54:58 UTC
MARKED AS SPAM
Comment 3 Mark Johnston freebsd_committer freebsd_triage 2024-01-18 19:57:18 UTC
OBE per comment 1.