mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/dl/handle.c (rb_dlhandle_sym): get rid of buffer overrun,
and try ASCII WINAPI versions too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9fb56049eb
commit
46e06b572b
2 changed files with 30 additions and 30 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Mar 2 10:50:53 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/dl/handle.c (rb_dlhandle_sym): get rid of buffer overrun,
|
||||
and try ASCII WINAPI versions too.
|
||||
|
||||
Mon Mar 2 10:29:17 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_longjmp), include/ruby/intern.h (ruby_cleanup): fixed
|
||||
|
|
|
@ -160,53 +160,48 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
|
|||
func = dlsym(handle, name);
|
||||
CHECK_DLERROR;
|
||||
if( !func ){
|
||||
#if defined(__CYGWIN__) || defined(WIN32) || defined(__MINGW32__)
|
||||
int len = strlen(name);
|
||||
char *name_n;
|
||||
#if defined(__CYGWIN__) || defined(_WIN32) || defined(__MINGW32__)
|
||||
{
|
||||
int len = strlen(name);
|
||||
char *name_a = (char*)xmalloc(len+2);
|
||||
strcpy(name_a, name);
|
||||
name_a[len] = 'A';
|
||||
name_a[len+1] = '\0';
|
||||
func = dlsym(handle, name_a);
|
||||
xfree(name_a);
|
||||
CHECK_DLERROR;
|
||||
if( !func ){
|
||||
for( i = 0; i < 256; i += 4 ){
|
||||
int len = strlen(name);
|
||||
char *name_n = (char*)xmalloc(len+5);
|
||||
sprintf(name_n, "%s@%d%c", name, i, 0);
|
||||
func = dlsym(handle, name_n);
|
||||
xfree(name_n);
|
||||
CHECK_DLERROR;
|
||||
if( func )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
CHECK_DLERROR;
|
||||
if( !func ){
|
||||
rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
|
||||
}
|
||||
if( func ){
|
||||
xfree(name_a);
|
||||
goto found;
|
||||
}
|
||||
name_n = xrealloc(name_a, len+6);
|
||||
}
|
||||
#else
|
||||
name_n = (char*)xmalloc(len+6);
|
||||
#endif
|
||||
memcpy(name_n, name, len);
|
||||
name_n[len++] = '@';
|
||||
for( i = 0; i < 256; i += 4 ){
|
||||
int len = strlen(name);
|
||||
char *name_n = (char*)xmalloc(len+4);
|
||||
sprintf(name_n, "%s@%d", name, i);
|
||||
sprintf(name_n + len, "%d", i);
|
||||
func = dlsym(handle, name_n);
|
||||
xfree(name_n);
|
||||
CHECK_DLERROR;
|
||||
if( func ){
|
||||
break;
|
||||
}
|
||||
if( func ) break;
|
||||
}
|
||||
CHECK_DLERROR;
|
||||
if( !func ){
|
||||
xfree(name_n);
|
||||
if( func ) goto found;
|
||||
name_n[len-1] = 'A';
|
||||
name_n[len++] = '@';
|
||||
for( i = 0; i < 256; i += 4 ){
|
||||
sprintf(name_n + len, "%d", i);
|
||||
func = dlsym(handle, name_n);
|
||||
CHECK_DLERROR;
|
||||
if( func ) break;
|
||||
}
|
||||
if( !func ){
|
||||
rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
found:
|
||||
|
||||
return PTR2NUM(func);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue