Bug 12037 - Feature test macros incorrect for ftruncate() (and probably also truncate())
Summary: Feature test macros incorrect for ftruncate() (and probably also truncate())
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.12
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-18 12:35 UTC by Michael Kerrisk
Modified: 2014-06-30 08:02 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Kerrisk 2010-09-18 12:35:51 UTC
I've just been documenting the new feature test macro requirements for
truncate() and ftruncate() in glibc 2.12, and it appears that the FTMs for
ftruncate() are incorrect.

Some background. In POSIX, these functions are marked as follows:

POSIX.1-2001/SUSv3
ftruncate() no markings
truncate() marked XSI

POSIX.1-2008/SUSv4
ftruncate() no markings
truncate() no markings

Here's the history of feature test macro requirements for these two functions as
defined in <unistd.h>:

       truncate():
           Since glibc 2.12
               _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
               _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED ||
               _POSIX_C_SOURCE >= 200809L
           Before glibc 2.12:
               _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
               _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED

       ftruncate():
           Since glibc 2.12:
               _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
               _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED ||
               _POSIX_C_SOURCE >= 200809L
           Between glibc 2.3.5 and 2.11
               _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
               _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED ||
               _POSIX_C_SOURCE >= 200112L
           Before glibc 2.3.5:
               _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
               _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED

From the above, ftruncate() is no longer exposed in glibc 2.12 if
_POSIX_C_SOURCE >= 200112. This seems pretty clearly incorrect. I belive the
FTMs governing the declaration should have remained as they were pre 2.12:

#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
Comment 1 Ulrich Drepper 2010-09-21 18:03:52 UTC
Fixed in git.