From 655e96fa59f62f7d31b2d9d470947f97aceb7b92 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 9 May 2000 04:53:16 +0000 Subject: 2000-05-09 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- dln.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'dln.c') diff --git a/dln.c b/dln.c index a44c5a78c3..beef2f74a5 100644 --- a/dln.c +++ b/dln.c @@ -98,7 +98,7 @@ init_funcname(buf, file) if (*p == '/') slash = p; #endif - sprintf(buf, FUNCNAME_PATTERN, slash + 1); + snprintf(buf, MAXPATHLEN, FUNCNAME_PATTERN, slash + 1); for (p = buf; *p; p++) { /* Delete suffix if it exists */ if (*p == '.') { *p = '\0'; break; @@ -367,6 +367,10 @@ dln_init(prog) while (read(fd, p, 1) == 1) { if (*p == '\n' || *p == '\t' || *p == ' ') break; p++; + if (p-buf >= MAXPATHLEN) { + dln_errno = ENAMETOOLONG; + return -1; + } } *p = '\0'; @@ -605,7 +609,7 @@ load_1(fd, disp, need_init) struct nlist *sym; struct nlist *end; int init_p = 0; - char buf[256]; + char buf[MAXPATHLEN]; if (load_header(fd, &hdr, disp) == -1) return -1; if (INVALID_OBJECT(hdr)) { @@ -1181,7 +1185,7 @@ aix_loaderror(const char *pathname) #define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0])) #define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1) - sprintf(errbuf, "load failed - %.200s ", pathname); + snprintf(errbuf, 1024, "load failed - %.200s ", pathname); if (!loadquery(1, &message[0], sizeof(message))) ERRBUF_APPEND(strerror(errno)); @@ -1407,20 +1411,20 @@ dln_load(file) } /* find symbol for module initialize function. */ - /* The Be Book KernelKit Images section described to use - B_SYMBOL_TYPE_TEXT for symbol of function, not - B_SYMBOL_TYPE_CODE. Why ? */ - /* strcat(init_fct_symname, "__Fv"); */ /* parameter nothing. */ - /* "__Fv" dont need! The Be Book Bug ? */ + /* The Be Book KernelKit Images section described to use + B_SYMBOL_TYPE_TEXT for symbol of function, not + B_SYMBOL_TYPE_CODE. Why ? */ + /* strcat(init_fct_symname, "__Fv"); */ /* parameter nothing. */ + /* "__Fv" dont need! The Be Book Bug ? */ err_stat = get_image_symbol(img_id, buf, B_SYMBOL_TYPE_TEXT, (void **)&init_fct); if (err_stat != B_NO_ERROR) { - char real_name[1024]; - strcpy(real_name, buf); - strcat(real_name, "__Fv"); + char real_name[MAXPATHLEN]; + strcpy(real_name, buf); + strcat(real_name, "__Fv"); err_stat = get_image_symbol(img_id, real_name, - B_SYMBOL_TYPE_TEXT, (void **)&init_fct); + B_SYMBOL_TYPE_TEXT, (void **)&init_fct); } if ((B_BAD_IMAGE_ID == err_stat) || (B_BAD_INDEX == err_stat)) { -- cgit v1.2.3