From: Bruno Haible Date: Sat, 12 Jul 2025 11:50:24 +0000 (+0200) Subject: obstack-printf: Fix memory overrun on glibc systems. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e331cab96b9e92f70a17931b85bfaae68af080a1;p=thirdparty%2Fgnulib.git obstack-printf: Fix memory overrun on glibc systems. * m4/obstack.m4 (gl_FUNC_OBSTACK): Define through AC_DEFUN_ONCE. * m4/obstack-printf.m4 (gl_FUNC_OBSTACK_PRINTF): Require gl_FUNC_OBSTACK. Invoke gl_REPLACE_OBSTACK_PRINTF when using the 'obstack' replacement code. --- diff --git a/ChangeLog b/ChangeLog index b8f57f4902..ebc4ef2a64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2025-07-12 Bruno Haible + + obstack-printf: Fix memory overrun on glibc systems. + * m4/obstack.m4 (gl_FUNC_OBSTACK): Define through AC_DEFUN_ONCE. + * m4/obstack-printf.m4 (gl_FUNC_OBSTACK_PRINTF): Require + gl_FUNC_OBSTACK. Invoke gl_REPLACE_OBSTACK_PRINTF when using the + 'obstack' replacement code. + 2025-07-10 Bruno Haible string-h: Fix compilation error on macOS with fortify. diff --git a/m4/obstack-printf.m4 b/m4/obstack-printf.m4 index 05ca0af650..eeee458484 100644 --- a/m4/obstack-printf.m4 +++ b/m4/obstack-printf.m4 @@ -1,5 +1,5 @@ # obstack-printf.m4 -# serial 4 +# serial 5 dnl Copyright (C) 2008-2025 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,12 +12,17 @@ dnl obstack_vprintf behaves identically, so we only test for one. AC_DEFUN([gl_FUNC_OBSTACK_PRINTF], [ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_OBSTACK]) + dnl Persuade glibc to declare obstack_printf(), obstack_vprintf(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_STDIO_H_DEFAULTS]) AC_CHECK_FUNCS_ONCE([obstack_printf]) - if test $ac_cv_func_obstack_printf = no ; then + dnl The obstack_printf function from glibc does not work with the + dnl 'struct obstack' defined in gnulib's . Therefore, when + dnl overriding 'struct obstack', we must also override obstack_printf. + if test $HAVE_OBSTACK = 0 || test $REPLACE_OBSTACK = 1; then gl_REPLACE_OBSTACK_PRINTF fi diff --git a/m4/obstack.m4 b/m4/obstack.m4 index 15f667332a..161370f86e 100644 --- a/m4/obstack.m4 +++ b/m4/obstack.m4 @@ -1,5 +1,5 @@ # obstack.m4 -# serial 2 +# serial 3 dnl Copyright 1996-2025 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,7 +11,7 @@ dnl This file is offered as-is, without any warranty. dnl Autoconf's AC_FUNC_OBSTACK is marked obsolete since version 2.70. dnl We provide our own macro here. -AC_DEFUN([gl_FUNC_OBSTACK], +AC_DEFUN_ONCE([gl_FUNC_OBSTACK], [ AC_CHECK_HEADERS_ONCE([obstack.h]) if test $ac_cv_header_obstack_h = yes; then