]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
obstack-printf: Fix memory overrun on glibc systems.
authorBruno Haible <bruno@clisp.org>
Sat, 12 Jul 2025 11:50:24 +0000 (13:50 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 12 Jul 2025 11:54:23 +0000 (13:54 +0200)
* 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.

ChangeLog
m4/obstack-printf.m4
m4/obstack.m4

index b8f57f49029c6531f32f019f799f49f61d1dbeaf..ebc4ef2a640574208b018b56b43dd8c86dc1f28d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-07-12  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        string-h: Fix compilation error on macOS with fortify.
index 05ca0af650274db3f260b5a06318afb4b93c7ca2..eeee458484328ca4bd13fa97d7126c30c00cf91b 100644 (file)
@@ -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 <stdio.h> 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 <obstack.h>.  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
 
index 15f667332a2faa812bb9157b9bbd0c44ba285d7a..161370f86ecfcc2ca770e50a1cc80128f065f016 100644 (file)
@@ -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