]> git.sesse.net Git - vlc/blobdiff - bin/override.c
Use setenv(), safer and cleaner than putenv()
[vlc] / bin / override.c
index 5996e43c499b44067a2b67b8d4cdbf1840062dc1..b5de22d0f558b4c941937048c63ea11c75ffc0a9 100644 (file)
@@ -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
@@ -216,7 +217,8 @@ void (*signal (int signum, void (*handler) (int))) (int)
         if (!blocked_signal (signum))
             goto error;
         /* For our blocked signals, the handler won't matter much... */
-        LOG("Warning", "%d, %p", signum, handler);
+        if (handler == SIG_DFL)
+            LOG("Warning", "%d, SIG_DFL", signum, handler);
     }
     return CALL(signal, signum, handler);
 error:
@@ -231,7 +233,8 @@ int sigaction (int signum, const struct sigaction *act, struct sigaction *old)
         if ((act->sa_flags & SA_SIGINFO)
          || (act->sa_handler != SIG_IGN && act->sa_handler != SIG_DFL))
             goto error;
-        LOG("Warning", "%d, %p, %p", signum, act, old);
+        if (act->sa_handler == SIG_DFL)
+            LOG("Warning", "%d, %p, SIG_DFL", signum, act);
     }
     return CALL(sigaction, signum, act, old);
 error:
@@ -258,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>