diff options
author | kanemoto <kanemoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-05 12:55:02 +0000 |
---|---|---|
committer | kanemoto <kanemoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-05 12:55:02 +0000 |
commit | 0882e74bf632b5003c8d02c54798f74f4c292d7e (patch) | |
tree | ba9d92118abc48fdafe081a7f0e24b66f7096a18 /dln.c | |
parent | bd21118627cbf27f678fc6386e8c7effe67f4cdd (diff) |
* dln.c (aix_loaderror): use execerror for load error on AIX.
This can avoid SEGV reported by Perry Smith. [Bug #2063]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r-- | dln.c | 56 |
1 files changed, 17 insertions, 39 deletions
@@ -1174,47 +1174,25 @@ dln_strerror(void) static void aix_loaderror(const char *pathname) { - char *message[1024], errbuf[1024]; - int i,j; - - static const struct errtab { - int errnum; - const char * errstr; - } load_errtab[] = { - {L_ERROR_TOOMANY, "too many errors, rest skipped."}, - {L_ERROR_NOLIB, "can't load library:"}, - {L_ERROR_UNDEF, "can't find symbol in library:"}, - {L_ERROR_RLDBAD, - "RLD index out of range or bad relocation type:"}, - {L_ERROR_FORMAT, "not a valid, executable xcoff file:"}, - {L_ERROR_MEMBER, - "file not an archive or does not contain requested member:"}, - {L_ERROR_TYPE, "symbol table mismatch:"}, - {L_ERROR_ALIGN, "text alignment in file is wrong."}, - {L_ERROR_SYSTEM, "System error:"}, - {L_ERROR_ERRNO, NULL} - }; - -#define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0])) + char *message[1024], errbuf[1024]; + int i; #define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1) - - snprintf(errbuf, sizeof(errbuf), "load failed - %s ", pathname); - - message[0] = NULL; - if (!loadquery(L_GETMESSAGES, &message[0], sizeof(message))) - ERRBUF_APPEND(strerror(errno)); - for(i = 0; message[i] && *message[i]; i++) { - int nerr = atoi(message[i]); - for (j=0; j<LOAD_ERRTAB_LEN; j++) { - if (nerr == load_errtab[j].errnum && load_errtab[j].errstr) - ERRBUF_APPEND(load_errtab[j].errstr); - } - while (isdigit(*message[i])) message[i]++; - ERRBUF_APPEND(message[i]); - ERRBUF_APPEND("\n"); + snprintf(errbuf, sizeof(errbuf), "load failed - %s. ", pathname); + + if (loadquery(L_GETMESSAGES, &message[0], sizeof(message)) != -1) { + ERRBUF_APPEND("Please issue below command for detailed reasons:\n\t"); + ERRBUF_APPEND("/usr/sbin/execerror ruby "); + for (i=0; message[i]; i++) { + ERRBUF_APPEND("\""); + ERRBUF_APPEND(message[i]); + ERRBUF_APPEND("\" "); } - errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */ - dln_loaderror("%s", errbuf); + ERRBUF_APPEND("\n"); + } else { + ERRBUF_APPEND(strerror(errno)); + ERRBUF_APPEND("[loadquery failed]"); + } + dln_loaderror("%s", errbuf); } #endif |