This is the mail archive of the libc-hacker@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

dlopen uniqueness bug


Reported by Mike Shaver (shaver@netscape.com)

Repeat as

	gcc -shared -o /tmp/dll.so dll.c
	gcc -o /tmp/main main.c
	cd /tmp
	./main

We are only checking uniqueness of filename, not of file.  We should
be using stat to make sure the so isn't already loaded.  Solaris
gets this right.



r~
#include <stdio.h>
#include <dlfcn.h>

int main(int argc, char** argv)
{
  void *a, *b, *c, *d;

  /* Load the same dll several times */
  a = dlopen("./dll.so", RTLD_NOW);
  b = dlopen("./../tmp/dll.so", RTLD_NOW);
  c = dlopen("/tmp/dll.so", RTLD_NOW);
  d = dlopen("/tmp/../tmp/dll.so", RTLD_NOW);

  if (a == b && b == c && c == d)
    printf("ok\n");
  else
    printf("a = %p, b = %p, c = %p, d = %p\n", a, b, c, d);
}
#include <stdio.h>

void foo(void)
{
  printf("foo in dll called\n");
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]