|
|||||||||||
|
system/3371: Incorrect function called via pointer when using dynamicly loaded code
From: <openbsd(at)codebunny.org>
Date: Sun Jul 27 2003 - 17:13:33 EDT
System : OpenBSD 3.3 Architecture: OpenBSD.i386 Machine : i386 >Description: A program dynamicly loads 2 (or more) objects. Within each module is a function of a particular name, which is 'private', i.e. the function is not declared in any included headers. If, within a module, the 'private' (I know, bad terminology) function is called via pointer, the function actually called will be the 'private' function in the first loaded module. >How-To-Repeat:
printf("hello from one\n"); } void start(void) { void (*func)(void); func = hello; func(); }
printf("hello from two\n"); } void start(void) { void (*func)(void); func = hello; func(); }
#define DL_PREFIX "_" int main(void) {
void *handleOne;
void *handleTwo;
void (*startOne)(void);
void (*startTwo)(void);
handleOne = dlopen("./one.so", RTLD_LAZY);
handleTwo = dlopen("./two.so", RTLD_LAZY);
startOne = dlsym(handleOne, DL_PREFIX "start");
startTwo = dlsym(handleTwo, DL_PREFIX "start");
startTwo();
dlclose(handleOne);
dlclose(handleTwo);
exit(0);
}
>Fix:
>Release-Note:
This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:30:01 EDT |
||||||||||
|
|||||||||||