* 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-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.
# 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,
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
# 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,
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