mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
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
This commit is contained in:
parent
637e8b5e1c
commit
91c42b9380
1 changed files with 4 additions and 11 deletions
|
@ -36,18 +36,11 @@
|
||||||
#define realloc g_realloc
|
#define realloc g_realloc
|
||||||
#define free g_free
|
#define free g_free
|
||||||
|
|
||||||
/* If GLib is using the system printf, we can assume C99 behaviour */
|
/* Don't use snprintf(); we have to use sprintf instead and do our own
|
||||||
#ifdef GLIB_USING_SYSTEM_PRINTF
|
* length calculations, because glibc doesn't allow passing %n in a format
|
||||||
#define HAVE_C99_SNPRINTF
|
* string if the string is in writable memory (if glibc has been compiled
|
||||||
#endif
|
* with _FORTIFY_SOURCE=2 which seems to be the case on some distros/systems) */
|
||||||
|
|
||||||
/* Ensure only C99 snprintf gets used */
|
|
||||||
#undef HAVE_SNPRINTF
|
#undef HAVE_SNPRINTF
|
||||||
#ifdef HAVE_C99_SNPRINTF
|
|
||||||
#define HAVE_SNPRINTF 1
|
|
||||||
#else
|
|
||||||
#undef HAVE_SNPRINTF
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* based on glib's config.h.win32.in */
|
/* based on glib's config.h.win32.in */
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
|
Loading…
Reference in a new issue