Bug 22028 - bits/math-finite.h _MSUF_ expansion namespace
Summary: bits/math-finite.h _MSUF_ expansion namespace
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.27
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-29 13:56 UTC by Joseph Myers
Modified: 2017-08-30 12:22 UTC (History)
0 users

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 Joseph Myers 2017-08-29 13:56:20 UTC
The current bits/math-finite.h approach to defining functions for different types, involving math.h defining _MSUF_ and _MSUFTO_ for the function suffixes involved, is not namespace-clean if one of those suffixes (f, l, f128) is defined as a macro by the user before math.h is included; too many levels of macro expansion occur.  Instead, those suffixes should appear directly in the expansion of the macro using ## so they don't get expanded even if defined as macros by the user (that is, math.h should be defining __REDIRFROM_X and __REDIRTO_X directly to use those suffixes rather than suffixes being passed as an argument by macro callers).

Testing a patch.
Comment 1 Sourceware Commits 2017-08-29 14:16:35 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  7daada0319613fec8c2a10b28eed911f4d359a6a (commit)
      from  1cf1232cd4721dc155a5cf7d571e5b1dae506430 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7daada0319613fec8c2a10b28eed911f4d359a6a

commit 7daada0319613fec8c2a10b28eed911f4d359a6a
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Tue Aug 29 14:15:37 2017 +0000

    Fix bits/math-finite.h _MSUF_ expansion namespace (bug 22028).
    
    The current bits/math-finite.h approach to defining functions for
    different types, involving math.h defining _MSUF_ and _MSUFTO_ for the
    function suffixes involved, is not namespace-clean if one of those
    suffixes (f, l, f128) is defined as a macro by the user before math.h
    is included; too many levels of macro expansion occur.  Instead, those
    suffixes should appear directly in the expansion of the macro using ##
    so they don't get expanded even if defined as macros by the user (that
    is, math.h should be defining __REDIRFROM_X and __REDIRTO_X directly
    to use those suffixes rather than suffixes being passed as an argument
    by macro callers).  This patch makes that change.
    
    Tested for x86_64.
    
    	[BZ #22028]
    	* math/math.h [__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0]
    	(_MSUF_): Remove macro.
    	[__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (_MSUFTO_):
    	Likewise.
    	[__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0]
    	(__REDIRFROM_X): New macro.
    	[__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (__REDIRTO_X):
    	Likewise.
    	* math/bits/math-finite.h (__REDIRFROM_X): Remove macro.
    	(__REDIRTO_X): Likewise.
    	(__MATH_REDIRCALL): Do not pass _MSUF_ or _MSUFTO_ macro
    	arguments.
    	(__MATH_REDIRCALL_2): Likewise.
    	(__MATH_REDIRCALL_INTERNAL): Likewise.
    	(__REDIRFROM (lgamma, , _MSUF_)): Likewise.
    	(__REDIRFROM (gamma, , _MSUF_)): Likweise.
    	(__REDIRFROM (__gamma, _r_finite, _MSUF_)): Likewise.
    	(__REDIRFROM (tgamma, , _MSUF_)): Likewise.
    	* math/test-finite-macros.c: New file.
    	* math/Makefile (tests): Add test-finite-macros.
    	(CFLAGS-test-finite-macros.c): New variable.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                      |   25 +++++++++++++
 math/Makefile                                  |    4 ++-
 math/bits/math-finite.h                        |   34 +++++++----------
 math/math.h                                    |   46 ++++++++++++++---------
 debug/tst-ssp-1.c => math/test-finite-macros.c |   28 +++++----------
 5 files changed, 79 insertions(+), 58 deletions(-)
 copy debug/tst-ssp-1.c => math/test-finite-macros.c (70%)
Comment 2 Joseph Myers 2017-08-29 14:17:18 UTC
Fixed for 2.27.