From 91c42b938001bfd68acb6af951603cebc1bea75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 14 Apr 2013 11:23:10 +0100 Subject: [PATCH] printf: use sprintf() to work around glibc complaining about %n in a writable format string Don't use snprintf(), but use sprintf instead and do our own length calculations, because glibc may complain about us passing %n in a format string if the string is in writable memory, and here the format string is always in writable memory since we construct it on the fly. This happens if glibc has been compiled with _FORTIFY_SOURCE=2, which seems to be the case on some distros/systems). On the upside, we now use the sprintf code path on all systems which should be better from a maintenance point of view. https://bugzilla.gnome.org/show_bug.cgi?id=697970 --- gst/printf/gst-printf.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/gst/printf/gst-printf.h b/gst/printf/gst-printf.h index 1921550721..b7d55a9b8c 100644 --- a/gst/printf/gst-printf.h +++ b/gst/printf/gst-printf.h @@ -36,18 +36,11 @@ #define realloc g_realloc #define free g_free -/* If GLib is using the system printf, we can assume C99 behaviour */ -#ifdef GLIB_USING_SYSTEM_PRINTF -#define HAVE_C99_SNPRINTF -#endif - -/* Ensure only C99 snprintf gets used */ +/* Don't use snprintf(); we have to use sprintf instead and do our own + * length calculations, because glibc doesn't allow passing %n in a format + * string if the string is in writable memory (if glibc has been compiled + * with _FORTIFY_SOURCE=2 which seems to be the case on some distros/systems) */ #undef HAVE_SNPRINTF -#ifdef HAVE_C99_SNPRINTF -#define HAVE_SNPRINTF 1 -#else -#undef HAVE_SNPRINTF -#endif /* based on glib's config.h.win32.in */ #ifdef G_OS_WIN32