Pointer 'ptr', returned from function 'xmalloc_open_zipped_read_close' may be 
NULL
and is dereferenced by call function 'is_prefixed_with'.

Dynamic memory, referenced by fields of 'e' is allocated and lost when function
finishes executing.

Found by RASU JSC with SVACE.

Signed-off-by: Maks Mishin <[email protected]>
---
 modutils/depmod.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/modutils/depmod.c b/modutils/depmod.c
index bb42bbefe..abf39bfe9 100644
--- a/modutils/depmod.c
+++ b/modutils/depmod.c
@@ -47,6 +47,8 @@ static int FAST_FUNC parse_module(struct recursive_state 
*state,
                return TRUE;
 
        image = xmalloc_open_zipped_read_close(fname, &len);
+       if (image == NULL)
+               return FALSE;
 
        e = moddb_get_or_create(modules, 
bb_get_last_path_component_nostrip(fname));
        e->name = xstrdup(fname + 2); /* skip "./" */
@@ -79,6 +81,11 @@ static int FAST_FUNC parse_module(struct recursive_state 
*state,
                }
        }
        free(image);
+       free(e->name);
+       llist_free(e->deps, free);
+       llist_free(e->aliases, free);
+       llist_free(e->symbols, free);
+       free(e);
 
        return TRUE;
 }
-- 
2.34.1

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to