Applied patch from John Lombardo to fix OOM in insmod.

This commit is contained in:
Mark Whitley 2001-03-12 23:08:34 +00:00
parent 6317c4baf7
commit 94fd480bab
2 changed files with 82 additions and 78 deletions

View file

@ -119,7 +119,7 @@
#ifndef MODUTILS_MODULE_H #ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1; static const int MODUTILS_MODULE_H = 1;
#ident "$Id: insmod.c,v 1.50 2001/02/24 20:01:53 andersen Exp $" #ident "$Id: insmod.c,v 1.51 2001/03/12 23:08:34 markw Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels. /* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish We do not use the kernel headers directly because we do not wish
@ -325,7 +325,7 @@ int delete_module(const char *);
#ifndef MODUTILS_OBJ_H #ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1; static const int MODUTILS_OBJ_H = 1;
#ident "$Id: insmod.c,v 1.50 2001/02/24 20:01:53 andersen Exp $" #ident "$Id: insmod.c,v 1.51 2001/03/12 23:08:34 markw Exp $"
/* The relocatable object is manipulated using elfin types. */ /* The relocatable object is manipulated using elfin types. */
@ -2306,11 +2306,12 @@ static int new_get_kernel_symbols(void)
} }
n_ext_modules = nmod = ret; n_ext_modules = nmod = ret;
ext_modules = modules = xmalloc(nmod * sizeof(*modules));
memset(modules, 0, nmod * sizeof(*modules));
/* Collect the modules' symbols. */ /* Collect the modules' symbols. */
if (nmod){
ext_modules = modules = xmalloc(nmod * sizeof(*modules));
memset(modules, 0, nmod * sizeof(*modules));
for (i = 0, mn = module_names, m = modules; for (i = 0, mn = module_names, m = modules;
i < nmod; ++i, ++m, mn += strlen(mn) + 1) { i < nmod; ++i, ++m, mn += strlen(mn) + 1) {
struct new_module_info info; struct new_module_info info;
@ -2350,6 +2351,7 @@ static int new_get_kernel_symbols(void)
s->name += (unsigned long) syms; s->name += (unsigned long) syms;
} }
} }
}
/* Collect the kernel's symbols. */ /* Collect the kernel's symbols. */

View file

@ -119,7 +119,7 @@
#ifndef MODUTILS_MODULE_H #ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1; static const int MODUTILS_MODULE_H = 1;
#ident "$Id: insmod.c,v 1.50 2001/02/24 20:01:53 andersen Exp $" #ident "$Id: insmod.c,v 1.51 2001/03/12 23:08:34 markw Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels. /* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish We do not use the kernel headers directly because we do not wish
@ -325,7 +325,7 @@ int delete_module(const char *);
#ifndef MODUTILS_OBJ_H #ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1; static const int MODUTILS_OBJ_H = 1;
#ident "$Id: insmod.c,v 1.50 2001/02/24 20:01:53 andersen Exp $" #ident "$Id: insmod.c,v 1.51 2001/03/12 23:08:34 markw Exp $"
/* The relocatable object is manipulated using elfin types. */ /* The relocatable object is manipulated using elfin types. */
@ -2306,11 +2306,12 @@ static int new_get_kernel_symbols(void)
} }
n_ext_modules = nmod = ret; n_ext_modules = nmod = ret;
ext_modules = modules = xmalloc(nmod * sizeof(*modules));
memset(modules, 0, nmod * sizeof(*modules));
/* Collect the modules' symbols. */ /* Collect the modules' symbols. */
if (nmod){
ext_modules = modules = xmalloc(nmod * sizeof(*modules));
memset(modules, 0, nmod * sizeof(*modules));
for (i = 0, mn = module_names, m = modules; for (i = 0, mn = module_names, m = modules;
i < nmod; ++i, ++m, mn += strlen(mn) + 1) { i < nmod; ++i, ++m, mn += strlen(mn) + 1) {
struct new_module_info info; struct new_module_info info;
@ -2350,6 +2351,7 @@ static int new_get_kernel_symbols(void)
s->name += (unsigned long) syms; s->name += (unsigned long) syms;
} }
} }
}
/* Collect the kernel's symbols. */ /* Collect the kernel's symbols. */