Bug 28746 - _FORTIFY_SOURCE does not work for stpcpy
Summary: _FORTIFY_SOURCE does not work for stpcpy
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.35
: P2 normal
Target Milestone: 2.35
Assignee: Siddhesh Poyarekar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-04 19:27 UTC by Siddhesh Poyarekar
Modified: 2022-03-11 15:12 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Siddhesh Poyarekar 2022-01-04 19:27:30 UTC
The definition for the fortified version of stpcpy and a few other functions are incorrectly under __USE_GNU when they should be under __USE_XOPEN2K8 because of which, they don't get fortified when _GNU_SOURCE is not defined.

See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89748
Comment 1 Sourceware Commits 2022-01-12 18:06:56 UTC
The master branch has been updated by Siddhesh Poyarekar <siddhesh@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fcfc9086815bf0d277ad47a90ee3fda4c37acca8

commit fcfc9086815bf0d277ad47a90ee3fda4c37acca8
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date:   Wed Jan 12 23:34:48 2022 +0530

    debug: Synchronize feature guards in fortified functions [BZ #28746]
    
    Some functions (e.g. stpcpy, pread64, etc.) had moved to POSIX in the
    main headers as they got incorporated into the standard, but their
    fortified variants remained under __USE_GNU.  As a result, these
    functions did not get fortified when _GNU_SOURCE was not defined.
    
    Add test wrappers that check all functions tested in tst-chk0 at all
    levels with _GNU_SOURCE undefined and then use the failures to (1)
    exclude checks for _GNU_SOURCE functions in these tests and (2) Fix
    feature macro guards in the fortified function headers so that they're
    the same as the ones in the main headers.
    
    This fixes BZ #28746.
    
    Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Comment 2 Siddhesh Poyarekar 2022-01-12 18:08:56 UTC
Fixed.
Comment 3 Sourceware Commits 2022-03-11 15:12:36 UTC
The release/2.34/master branch has been updated by Siddhesh Poyarekar <siddhesh@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=224d8c1890b6c57c7e4e8ddbb792dd9552086704

commit 224d8c1890b6c57c7e4e8ddbb792dd9552086704
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date:   Wed Jan 12 23:34:48 2022 +0530

    debug: Synchronize feature guards in fortified functions [BZ #28746]
    
    Some functions (e.g. stpcpy, pread64, etc.) had moved to POSIX in the
    main headers as they got incorporated into the standard, but their
    fortified variants remained under __USE_GNU.  As a result, these
    functions did not get fortified when _GNU_SOURCE was not defined.
    
    Add test wrappers that check all functions tested in tst-chk0 at all
    levels with _GNU_SOURCE undefined and then use the failures to (1)
    exclude checks for _GNU_SOURCE functions in these tests and (2) Fix
    feature macro guards in the fortified function headers so that they're
    the same as the ones in the main headers.
    
    This fixes BZ #28746.
    
    Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
    (cherry picked from commit fcfc9086815bf0d277ad47a90ee3fda4c37acca8)