summaryrefslogtreecommitdiff
path: root/dln.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-05-09 04:53:16 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-05-09 04:53:16 +0000
commit655e96fa59f62f7d31b2d9d470947f97aceb7b92 (patch)
tree6b6bb0a6ce9e46b326dbde9378c3791a54be1dd5 /dln.c
parent2a34f89e354071d09c64a93bf3498dfa108f3e8c (diff)
2000-05-09
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r--dln.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/dln.c b/dln.c
index a44c5a7..beef2f7 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)) {