* dln.c (aix_loaderror): get rid of using uninitialized value in the

case loadquery fails.  fixed wrong index variable usage.  see
  [ruby-core:25479].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-09-11 00:45:13 +00:00
parent 848d6fd55e
commit 0966635873
2 changed files with 13 additions and 6 deletions

View File

@ -1,3 +1,9 @@
Fri Sep 11 09:45:11 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dln.c (aix_loaderror): get rid of using uninitialized value in the
case loadquery fails. fixed wrong index variable usage. see
[ruby-core:25479].
Fri Sep 11 07:52:43 2009 NARUSE, Yui <naruse@ruby-lang.org> Fri Sep 11 07:52:43 2009 NARUSE, Yui <naruse@ruby-lang.org>
* unicode.c (onigenc_unicode_property_name_to_ctype): * unicode.c (onigenc_unicode_property_name_to_ctype):

13
dln.c
View File

@ -1149,10 +1149,10 @@ dln_strerror(void)
static void static void
aix_loaderror(const char *pathname) aix_loaderror(const char *pathname)
{ {
char *message[8], errbuf[1024]; char *message[1024], errbuf[1024];
int i,j; int i,j;
struct errtab { static const struct errtab {
int errnum; int errnum;
char *errstr; char *errstr;
} load_errtab[] = { } load_errtab[] = {
@ -1173,15 +1173,16 @@ aix_loaderror(const char *pathname)
#define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0])) #define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0]))
#define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1) #define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1)
snprintf(errbuf, 1024, "load failed - %s ", pathname); snprintf(errbuf, sizeof(errbuf), "load failed - %s ", pathname);
if (!loadquery(1, &message[0], sizeof(message))) message[0] = NULL;
if (!loadquery(L_GETMESSAGE, &message[0], sizeof(message)))
ERRBUF_APPEND(strerror(errno)); ERRBUF_APPEND(strerror(errno));
for(i = 0; message[i] && *message[i]; i++) { for(i = 0; message[i] && *message[i]; i++) {
int nerr = atoi(message[i]); int nerr = atoi(message[i]);
for (j=0; j<LOAD_ERRTAB_LEN; j++) { for (j=0; j<LOAD_ERRTAB_LEN; j++) {
if (nerr == load_errtab[i].errnum && load_errtab[i].errstr) if (nerr == load_errtab[j].errnum && load_errtab[j].errstr)
ERRBUF_APPEND(load_errtab[i].errstr); ERRBUF_APPEND(load_errtab[j].errstr);
} }
while (isdigit(*message[i])) message[i]++; while (isdigit(*message[i])) message[i]++;
ERRBUF_APPEND(message[i]); ERRBUF_APPEND(message[i]);