diff -urpN busybox-1.13.2/modutils/modutils-24.c busybox-1.13.2-modprobe/modutils/modutils-24.c --- busybox-1.13.2/modutils/modutils-24.c 2008-11-29 07:48:56.000000000 +0100 +++ busybox-1.13.2-modprobe/modutils/modutils-24.c 2009-03-08 02:04:02.000000000 +0100 @@ -2150,7 +2150,7 @@ static struct obj_section *obj_create_al sec->name = name; sec->idx = newidx; if (size) - sec->contents = xmalloc(size); + sec->contents = xzalloc(size); obj_insert_section_load_order(f, sec); @@ -2165,7 +2165,7 @@ static struct obj_section *obj_create_al int newidx = f->header.e_shnum++; struct obj_section *sec; - f->sections = xrealloc(f->sections, (newidx + 1) * sizeof(sec)); + f->sections = xrealloc_vector(f->sections, 2, newidx); f->sections[newidx] = sec = arch_new_section(); sec->header.sh_type = SHT_PROGBITS; @@ -2175,7 +2175,7 @@ static struct obj_section *obj_create_al sec->name = name; sec->idx = newidx; if (size) - sec->contents = xmalloc(size); + sec->contents = xzalloc(size); sec->load_next = f->load_order; f->load_order = sec; @@ -2571,8 +2571,7 @@ static void new_get_kernel_symbols(void) /* Collect the modules' symbols. */ if (nmod) { - ext_modules = modules = xmalloc(nmod * sizeof(*modules)); - memset(modules, 0, nmod * sizeof(*modules)); + ext_modules = modules = xzalloc(nmod * sizeof(*modules)); for (i = 0, mn = module_names, m = modules; i < nmod; ++i, ++m, mn += strlen(mn) + 1) { struct new_module_info info; @@ -2652,13 +2651,14 @@ static int new_is_kernel_checksummed(voi } -static void new_create_this_module(struct obj_file *f, const char *m_name) +static void new_create_this_module(struct obj_file *f, const char *m_name) { struct obj_section *sec; sec = obj_create_alloced_section_first(f, ".this", tgt_sizeof_long, sizeof(struct new_module)); - memset(sec->contents, 0, sizeof(struct new_module)); + /* done by obj_create_alloced_section_first: */ + /*memset(sec->contents, 0, sizeof(struct new_module));*/ obj_add_symbol(f, SPFX "__this_module", -1, ELF_ST_INFO(STB_LOCAL, STT_OBJECT), sec->idx, 0, @@ -2965,9 +2965,9 @@ static void obj_allocate_commons(struct if (i == f->header.e_shnum) { struct obj_section *sec; + f->header.e_shnum++; f->sections = xrealloc_vector(f->sections, 2, i); f->sections[i] = sec = arch_new_section(); - f->header.e_shnum = i + 1; sec->header.sh_type = SHT_PROGBITS; sec->header.sh_flags = SHF_WRITE | SHF_ALLOC; @@ -3006,12 +3006,9 @@ static void obj_allocate_commons(struct for (i = 0; i < f->header.e_shnum; ++i) { struct obj_section *s = f->sections[i]; if (s->header.sh_type == SHT_NOBITS) { + s->contents = NULL; if (s->header.sh_size != 0) - s->contents = memset(xmalloc(s->header.sh_size), - 0, s->header.sh_size); - else - s->contents = NULL; - + s->contents = xzalloc(s->header.sh_size); s->header.sh_type = SHT_PROGBITS; } } @@ -3275,14 +3272,13 @@ static struct obj_file *obj_load(FILE *f case SHT_SYMTAB: case SHT_STRTAB: case SHT_RELM: + sec->contents = NULL; if (sec->header.sh_size > 0) { - sec->contents = xmalloc(sec->header.sh_size); + sec->contents = xzalloc(sec->header.sh_size); fseek(fp, sec->header.sh_offset, SEEK_SET); if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { bb_perror_msg_and_die("error reading ELF section data"); } - } else { - sec->contents = NULL; } break; diff -urpN busybox-1.13.2/modutils/modutils.c busybox-1.13.2-modprobe/modutils/modutils.c --- busybox-1.13.2/modutils/modutils.c 2008-11-09 18:28:03.000000000 +0100 +++ busybox-1.13.2-modprobe/modutils/modutils.c 2009-03-08 02:04:15.000000000 +0100 @@ -71,7 +71,7 @@ char * FAST_FUNC filename2modname(const if (modname == NULL) modname = xmalloc(MODULE_NAME_LEN); from = bb_get_last_path_component_nostrip(filename); - for (i = 0; i < MODULE_NAME_LEN && from[i] != '\0' && from[i] != '.'; i++) + for (i = 0; i < (MODULE_NAME_LEN-1) && from[i] != '\0' && from[i] != '.'; i++) modname[i] = (from[i] == '-') ? '_' : from[i]; modname[i] = 0; diff -urpN busybox-1.13.2/modutils/modutils.h busybox-1.13.2-modprobe/modutils/modutils.h --- busybox-1.13.2/modutils/modutils.h 2008-11-09 18:28:03.000000000 +0100 +++ busybox-1.13.2-modprobe/modutils/modutils.h 2009-03-08 02:04:15.000000000 +0100 @@ -16,8 +16,9 @@ # pragma GCC visibility push(hidden) #endif -/* As defined in linux/include/linux/module.h */ -#define MODULE_NAME_LEN 64 +/* linux/include/linux/module.h has 64, but this is also used + * internally for the maximum alias name length, which can be quite long */ +#define MODULE_NAME_LEN 256 const char *moderror(int err) FAST_FUNC; llist_t *llist_find(llist_t *first, const char *str) FAST_FUNC;