aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-04-26 19:29:58 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-04-26 19:29:58 +0000
commitb5982dcaceedb6e2c96c341a923d402a7cfc6e4b (patch)
treecedb68994122d2d8666a871f73401f72d9ec0d8d
parent3c75693d884e238eeccdf6d2d22589e2ff5c9321 (diff)
downloadbusybox-w32-b5982dcaceedb6e2c96c341a923d402a7cfc6e4b.tar.gz
busybox-w32-b5982dcaceedb6e2c96c341a923d402a7cfc6e4b.tar.bz2
busybox-w32-b5982dcaceedb6e2c96c341a923d402a7cfc6e4b.zip
A fix from Larry for a corner case where insmod could end up
doing an xrealloc(0). git-svn-id: svn://busybox.net/trunk/busybox@2463 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--insmod.c11
-rw-r--r--modutils/insmod.c11
2 files changed, 16 insertions, 6 deletions
diff --git a/insmod.c b/insmod.c
index 4dd14c6bc..27f4a50e2 100644
--- a/insmod.c
+++ b/insmod.c
@@ -124,7 +124,7 @@
124#ifndef MODUTILS_MODULE_H 124#ifndef MODUTILS_MODULE_H
125static const int MODUTILS_MODULE_H = 1; 125static const int MODUTILS_MODULE_H = 1;
126 126
127#ident "$Id: insmod.c,v 1.59 2001/04/25 17:22:32 andersen Exp $" 127#ident "$Id: insmod.c,v 1.60 2001/04/26 19:29:58 andersen Exp $"
128 128
129/* This file contains the structures used by the 2.0 and 2.1 kernels. 129/* This file contains the structures used by the 2.0 and 2.1 kernels.
130 We do not use the kernel headers directly because we do not wish 130 We do not use the kernel headers directly because we do not wish
@@ -330,7 +330,7 @@ int delete_module(const char *);
330#ifndef MODUTILS_OBJ_H 330#ifndef MODUTILS_OBJ_H
331static const int MODUTILS_OBJ_H = 1; 331static const int MODUTILS_OBJ_H = 1;
332 332
333#ident "$Id: insmod.c,v 1.59 2001/04/25 17:22:32 andersen Exp $" 333#ident "$Id: insmod.c,v 1.60 2001/04/26 19:29:58 andersen Exp $"
334 334
335/* The relocatable object is manipulated using elfin types. */ 335/* The relocatable object is manipulated using elfin types. */
336 336
@@ -1536,7 +1536,9 @@ struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
1536void *obj_extend_section(struct obj_section *sec, unsigned long more) 1536void *obj_extend_section(struct obj_section *sec, unsigned long more)
1537{ 1537{
1538 unsigned long oldsize = sec->header.sh_size; 1538 unsigned long oldsize = sec->header.sh_size;
1539 sec->contents = xrealloc(sec->contents, sec->header.sh_size += more); 1539 if (more) {
1540 sec->contents = xrealloc(sec->contents, sec->header.sh_size += more);
1541 }
1540 return sec->contents + oldsize; 1542 return sec->contents + oldsize;
1541} 1543}
1542 1544
@@ -2474,6 +2476,9 @@ new_init_module(const char *m_name, struct obj_file *f,
2474 tgt_long m_addr; 2476 tgt_long m_addr;
2475 2477
2476 sec = obj_find_section(f, ".this"); 2478 sec = obj_find_section(f, ".this");
2479 if (!sec || !sec->contents) {
2480 perror_msg_and_die("corrupt module %s?",m_name);
2481 }
2477 module = (struct new_module *) sec->contents; 2482 module = (struct new_module *) sec->contents;
2478 m_addr = sec->header.sh_addr; 2483 m_addr = sec->header.sh_addr;
2479 2484
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 4dd14c6bc..27f4a50e2 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -124,7 +124,7 @@
124#ifndef MODUTILS_MODULE_H 124#ifndef MODUTILS_MODULE_H
125static const int MODUTILS_MODULE_H = 1; 125static const int MODUTILS_MODULE_H = 1;
126 126
127#ident "$Id: insmod.c,v 1.59 2001/04/25 17:22:32 andersen Exp $" 127#ident "$Id: insmod.c,v 1.60 2001/04/26 19:29:58 andersen Exp $"
128 128
129/* This file contains the structures used by the 2.0 and 2.1 kernels. 129/* This file contains the structures used by the 2.0 and 2.1 kernels.
130 We do not use the kernel headers directly because we do not wish 130 We do not use the kernel headers directly because we do not wish
@@ -330,7 +330,7 @@ int delete_module(const char *);
330#ifndef MODUTILS_OBJ_H 330#ifndef MODUTILS_OBJ_H
331static const int MODUTILS_OBJ_H = 1; 331static const int MODUTILS_OBJ_H = 1;
332 332
333#ident "$Id: insmod.c,v 1.59 2001/04/25 17:22:32 andersen Exp $" 333#ident "$Id: insmod.c,v 1.60 2001/04/26 19:29:58 andersen Exp $"
334 334
335/* The relocatable object is manipulated using elfin types. */ 335/* The relocatable object is manipulated using elfin types. */
336 336
@@ -1536,7 +1536,9 @@ struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
1536void *obj_extend_section(struct obj_section *sec, unsigned long more) 1536void *obj_extend_section(struct obj_section *sec, unsigned long more)
1537{ 1537{
1538 unsigned long oldsize = sec->header.sh_size; 1538 unsigned long oldsize = sec->header.sh_size;
1539 sec->contents = xrealloc(sec->contents, sec->header.sh_size += more); 1539 if (more) {
1540 sec->contents = xrealloc(sec->contents, sec->header.sh_size += more);
1541 }
1540 return sec->contents + oldsize; 1542 return sec->contents + oldsize;
1541} 1543}
1542 1544
@@ -2474,6 +2476,9 @@ new_init_module(const char *m_name, struct obj_file *f,
2474 tgt_long m_addr; 2476 tgt_long m_addr;
2475 2477
2476 sec = obj_find_section(f, ".this"); 2478 sec = obj_find_section(f, ".this");
2479 if (!sec || !sec->contents) {
2480 perror_msg_and_die("corrupt module %s?",m_name);
2481 }
2477 module = (struct new_module *) sec->contents; 2482 module = (struct new_module *) sec->contents;
2478 m_addr = sec->header.sh_addr; 2483 m_addr = sec->header.sh_addr;
2479 2484