X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Flinux_specific.c;h=57b0805b77f702fcac59a460b02d3b281ce6b659;hb=376853e5d685a9dde50acbdc2524fa5d890aed83;hp=0bc2e09884881d600464e80e77c7652aadd51146;hpb=f5cbe602f46b9fda941cbb8a8faf8ad0d5f11fce;p=vlc diff --git a/src/misc/linux_specific.c b/src/misc/linux_specific.c index 0bc2e09884..57b0805b77 100644 --- a/src/misc/linux_specific.c +++ b/src/misc/linux_specific.c @@ -31,6 +31,7 @@ #if 0 #include #include +#include static void set_libvlc_path (void) { @@ -45,29 +46,34 @@ static void set_libvlc_path (void) if (maps == NULL) return; + char *line = NULL; + size_t linelen = 0; + uintptr_t needle = (uintptr_t)set_libvlc_path; + for (;;) { - char buf[5000], *dir, *end; - - if (fgets (buf, sizeof (buf), maps) == NULL) + ssize_t len = getline (&line, &linelen, maps); + if (len == -1) break; - dir = strchr (buf, '/'); + void *start, *end; + if (sscanf (line, "%p-%p", &start, &end) < 2) + continue; + if (needle < (uintptr_t)start || (uintptr_t)end <= needle) + continue; + char *dir = strchr (line, '/'); if (dir == NULL) continue; - end = strrchr (dir, '/'); + char *file = strrchr (line, '/'); if (end == NULL) continue; - if (strncmp (end + 1, "libvlc.so.", 10)) - continue; - - *end = '\0'; + *file = '\0'; printf ("libvlc at %s\n", dir); if (strlen (dir) < sizeof (libvlc_path)) strcpy (libvlc_path, dir); break; } - + free (line); fclose (maps); } #endif @@ -90,7 +96,9 @@ void system_Init (libvlc_int_t *libvlc, int *argc, const char *argv[]) fputs ("LibVLC has detected an unusable buggy GNU/libc version.\n" "Please update to version 2.8 or newer.\n", stderr); fflush (stderr); - //abort (); +#ifndef DISABLE_BUGGY_GLIBC_CHECK + abort (); +#endif } #endif