Details

[Home]

Issue of the Standard # S0207

Brief

Implementation of the basename() function in libc.so does not satisfy LSB 3.1.

Detailed Description

Implementation of basename() in glibc-2.3.5 does not satisfy LSB 3.1.
The following code causes segmentation fault:

extern char *basename(const char *); int main() { char* path="err////"; basename(path); return 0; }
Besides, the basename() function incorrectly returns an empty string for the following values of input parameter:

ValueExpected
"er//""er"
"NULL ""."
"""."
"////""/"
"//""/" or "//"

At the same time the implementation of the basename() function in glibc-2.3.5 satisfies POSIX since while compiling with libgen.h the ‘basename’ identifier is substituted by the ‘__xpg_basename’ identifier, which corresponds to the __xpg_basename() function that satisfies to the POSIX requirements for the basename() function.

As discussed at the LSB Summit, the above problem is a problem of LSB 3.1, which should require the POSIX-compliance of binary symbol ‘__xpg_basename’, but not of ‘basename’.

Problem location(s) in the standard

Linux Standard Base Core Specification 3.1, Chapter 13. Base Libraries, 13.3. Interfaces for libc, 13.3.17. Standard Library, 13.3.17.1. Interfaces for Standard Library

Possible consequences

Portability problems.

Possible solutions

1. Add to the LSB 3.1 the description of the __xpg_basename() function with note that it is only in the source standard (see __cxa_atexit).
2. Add

#define basename __xpg_basename
to the LSB SDK headers.

Accepted

LSB Bugzilla, 1430

Status

Fixed in LSB 3.1 Update 1

[Home]