diff options
author | Mark Whitley <markw@lineo.com> | 2001-03-12 23:08:34 +0000 |
---|---|---|
committer | Mark Whitley <markw@lineo.com> | 2001-03-12 23:08:34 +0000 |
commit | 94fd480babd9e9a3bc7c981fa2e1cca8ffe9cd60 (patch) | |
tree | a3966904f46260ddcd1e6e580c63a8c620e546ad /modutils | |
parent | 6317c4baf79c25d7f77897b064eb4f0b7d9f070e (diff) | |
download | busybox-w32-94fd480babd9e9a3bc7c981fa2e1cca8ffe9cd60.tar.gz busybox-w32-94fd480babd9e9a3bc7c981fa2e1cca8ffe9cd60.tar.bz2 busybox-w32-94fd480babd9e9a3bc7c981fa2e1cca8ffe9cd60.zip |
Applied patch from John Lombardo to fix OOM in insmod.
Diffstat (limited to 'modutils')
-rw-r--r-- | modutils/insmod.c | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/modutils/insmod.c b/modutils/insmod.c index 50f272edb..5391c8804 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -119,7 +119,7 @@ | |||
119 | #ifndef MODUTILS_MODULE_H | 119 | #ifndef MODUTILS_MODULE_H |
120 | static const int MODUTILS_MODULE_H = 1; | 120 | static const int MODUTILS_MODULE_H = 1; |
121 | 121 | ||
122 | #ident "$Id: insmod.c,v 1.50 2001/02/24 20:01:53 andersen Exp $" | 122 | #ident "$Id: insmod.c,v 1.51 2001/03/12 23:08:34 markw Exp $" |
123 | 123 | ||
124 | /* This file contains the structures used by the 2.0 and 2.1 kernels. | 124 | /* This file contains the structures used by the 2.0 and 2.1 kernels. |
125 | We do not use the kernel headers directly because we do not wish | 125 | We do not use the kernel headers directly because we do not wish |
@@ -325,7 +325,7 @@ int delete_module(const char *); | |||
325 | #ifndef MODUTILS_OBJ_H | 325 | #ifndef MODUTILS_OBJ_H |
326 | static const int MODUTILS_OBJ_H = 1; | 326 | static const int MODUTILS_OBJ_H = 1; |
327 | 327 | ||
328 | #ident "$Id: insmod.c,v 1.50 2001/02/24 20:01:53 andersen Exp $" | 328 | #ident "$Id: insmod.c,v 1.51 2001/03/12 23:08:34 markw Exp $" |
329 | 329 | ||
330 | /* The relocatable object is manipulated using elfin types. */ | 330 | /* The relocatable object is manipulated using elfin types. */ |
331 | 331 | ||
@@ -2306,48 +2306,50 @@ static int new_get_kernel_symbols(void) | |||
2306 | } | 2306 | } |
2307 | 2307 | ||
2308 | n_ext_modules = nmod = ret; | 2308 | n_ext_modules = nmod = ret; |
2309 | ext_modules = modules = xmalloc(nmod * sizeof(*modules)); | ||
2310 | memset(modules, 0, nmod * sizeof(*modules)); | ||
2311 | 2309 | ||
2312 | /* Collect the modules' symbols. */ | 2310 | /* Collect the modules' symbols. */ |
2313 | 2311 | ||
2314 | for (i = 0, mn = module_names, m = modules; | 2312 | if (nmod){ |
2315 | i < nmod; ++i, ++m, mn += strlen(mn) + 1) { | 2313 | ext_modules = modules = xmalloc(nmod * sizeof(*modules)); |
2316 | struct new_module_info info; | 2314 | memset(modules, 0, nmod * sizeof(*modules)); |
2317 | 2315 | for (i = 0, mn = module_names, m = modules; | |
2318 | if (query_module(mn, QM_INFO, &info, sizeof(info), &ret)) { | 2316 | i < nmod; ++i, ++m, mn += strlen(mn) + 1) { |
2319 | if (errno == ENOENT) { | 2317 | struct new_module_info info; |
2320 | /* The module was removed out from underneath us. */ | 2318 | |
2321 | continue; | 2319 | if (query_module(mn, QM_INFO, &info, sizeof(info), &ret)) { |
2322 | } | 2320 | if (errno == ENOENT) { |
2323 | perror_msg("query_module: QM_INFO: %s", mn); | 2321 | /* The module was removed out from underneath us. */ |
2324 | return 0; | 2322 | continue; |
2325 | } | 2323 | } |
2326 | 2324 | perror_msg("query_module: QM_INFO: %s", mn); | |
2327 | syms = xmalloc(bufsize = 1024); | ||
2328 | retry_mod_sym_load: | ||
2329 | if (query_module(mn, QM_SYMBOLS, syms, bufsize, &ret)) { | ||
2330 | switch (errno) { | ||
2331 | case ENOSPC: | ||
2332 | syms = xrealloc(syms, bufsize = ret); | ||
2333 | goto retry_mod_sym_load; | ||
2334 | case ENOENT: | ||
2335 | /* The module was removed out from underneath us. */ | ||
2336 | continue; | ||
2337 | default: | ||
2338 | perror_msg("query_module: QM_SYMBOLS: %s", mn); | ||
2339 | return 0; | 2325 | return 0; |
2340 | } | 2326 | } |
2341 | } | 2327 | |
2342 | nsyms = ret; | 2328 | syms = xmalloc(bufsize = 1024); |
2343 | 2329 | retry_mod_sym_load: | |
2344 | m->name = mn; | 2330 | if (query_module(mn, QM_SYMBOLS, syms, bufsize, &ret)) { |
2345 | m->addr = info.addr; | 2331 | switch (errno) { |
2346 | m->nsyms = nsyms; | 2332 | case ENOSPC: |
2347 | m->syms = syms; | 2333 | syms = xrealloc(syms, bufsize = ret); |
2348 | 2334 | goto retry_mod_sym_load; | |
2349 | for (j = 0, s = syms; j < nsyms; ++j, ++s) { | 2335 | case ENOENT: |
2350 | s->name += (unsigned long) syms; | 2336 | /* The module was removed out from underneath us. */ |
2337 | continue; | ||
2338 | default: | ||
2339 | perror_msg("query_module: QM_SYMBOLS: %s", mn); | ||
2340 | return 0; | ||
2341 | } | ||
2342 | } | ||
2343 | nsyms = ret; | ||
2344 | |||
2345 | m->name = mn; | ||
2346 | m->addr = info.addr; | ||
2347 | m->nsyms = nsyms; | ||
2348 | m->syms = syms; | ||
2349 | |||
2350 | for (j = 0, s = syms; j < nsyms; ++j, ++s) { | ||
2351 | s->name += (unsigned long) syms; | ||
2352 | } | ||
2351 | } | 2353 | } |
2352 | } | 2354 | } |
2353 | 2355 | ||