/[path-sandbox]/trunk/libsandbox/wrappers.c
Gentoo

Diff of /trunk/libsandbox/wrappers.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 370 Revision 371
40 40
41void *get_dlsym(const char *symname, const char *symver) 41void *get_dlsym(const char *symname, const char *symver)
42{ 42{
43 void *symaddr = NULL; 43 void *symaddr = NULL;
44 44
45 if (NULL == libc_handle) {
46#if !defined(USE_RTLD_NEXT) 45#if defined(USE_RTLD_NEXT)
46 libc_handle = RTLD_NEXT;
47#endif
48
49 /* Checking for -1UL is significent on hardened!
50 * USE_RTLD_NEXT returns it as a sign of being unusable.
51 * However using !x or NULL checks does NOT pick it up!
52 */
53#define INVALID_LIBC_HANDLE(x) (!x || NULL == x || -1UL == x)
54 if (INVALID_LIBC_HANDLE(libc_handle)) {
47 libc_handle = dlopen(LIBC_VERSION, RTLD_LAZY); 55 libc_handle = dlopen(LIBC_VERSION, RTLD_LAZY);
48 if (!libc_handle) { 56 if (INVALID_LIBC_HANDLE(libc_handle)) {
49 fprintf(stderr, "libsandbox: Can't dlopen libc: %s\n", 57 fprintf(stderr, "libsandbox: Can't dlopen libc: %s\n",
50 dlerror()); 58 dlerror());
51 exit(EXIT_FAILURE); 59 exit(EXIT_FAILURE);
52 } 60 }
53#else
54 libc_handle = RTLD_NEXT;
55#endif
56 } 61 }
62#undef INVALID_LIBC_HANDLE
57 63
58 if (NULL == symver) 64 if (NULL == symver)
59 symaddr = dlsym(libc_handle, symname); 65 symaddr = dlsym(libc_handle, symname);
60 else 66 else
61 symaddr = dlvsym(libc_handle, symname, symver); 67 symaddr = dlvsym(libc_handle, symname, symver);

Legend:
Removed from v.370  
changed lines
  Added in v.371

  ViewVC Help
Powered by ViewVC 1.1.20