[vlc-commits] commit: Catch unsafe (but alas common) strerror() ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Sun Apr 18 16:32:55 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 18 17:32:19 2010 +0300| [b67a5864cbcd069e3c0ad971745137469bb07ed6] | committer: Rémi Denis-Courmont 

Catch unsafe (but alas common) strerror()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b67a5864cbcd069e3c0ad971745137469bb07ed6
---

 bin/override.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/bin/override.c b/bin/override.c
index f3eebae..b5de22d 100644
--- a/bin/override.c
+++ b/bin/override.c
@@ -33,6 +33,7 @@ void vlc_enable_override (void);
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <dlfcn.h>
 #include <pthread.h>
 #ifdef HAVE_EXECINFO_H
@@ -260,6 +261,20 @@ char *setlocale (int cat, const char *locale)
 }
 
 
+/* strerror() is not thread-safe in theory (POSIX), nor in practice (glibc).
+ * This caused quite nasty crashes in the history of VLC/Linux. */
+char *strerror (int val)
+{
+    if (override)
+    {
+        static const char msg[] =
+            "Error message unavailable (use strerror_r instead of strerror)!";
+        LOG("Blocked", "%d", val);
+        return (char *)msg;
+    }
+    return CALL(strerror, val);
+}
+
 /*** Xlib ****/
 #ifdef HAVE_X11_XLIB_H
 # include <X11/Xlib.h>



More information about the vlc-commits mailing list