Commit b67a5864 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Catch unsafe (but alas common) strerror()

parent c3750154
...@@ -33,6 +33,7 @@ void vlc_enable_override (void); ...@@ -33,6 +33,7 @@ void vlc_enable_override (void);
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <pthread.h> #include <pthread.h>
#ifdef HAVE_EXECINFO_H #ifdef HAVE_EXECINFO_H
...@@ -260,6 +261,20 @@ char *setlocale (int cat, const char *locale) ...@@ -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 ****/ /*** Xlib ****/
#ifdef HAVE_X11_XLIB_H #ifdef HAVE_X11_XLIB_H
# include <X11/Xlib.h> # include <X11/Xlib.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment