trace: preload: avoid NULL-dereference here as well
authorDaniel Golle <daniel@makrotopia.org>
Mon, 30 Aug 2021 23:44:29 +0000 (00:44 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 30 Aug 2021 23:46:59 +0000 (00:46 +0100)
Fix potential NULL-pointer derefence in trace/preload.c similar to how
it was fixed in jail/preload.c by commit b824a89
("jail: preload: avoid NULL-dereference in case things go wrong").

Coverity CID: 1446096 Dereference after null check
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
trace/preload.c

index ee974290a90412fb3529e5b924deff3f25190915..457bd826fd4f92beac87e483ffff4ef548a3a9e0 100644 (file)
@@ -49,9 +49,10 @@ int __libc_start_main(main_t main,
        start_main_t __start_main__;
 
        __start_main__ = dlsym(RTLD_NEXT, "__libc_start_main");
-       if (!__start_main__)
+       if (!__start_main__) {
                ERROR("failed to find __libc_start_main %s\n", dlerror());
-
+               return -1;
+       }
        __main__ = main;
 
        return (*__start_main__)(__preload_main__, argc, argv, auxvec,
@@ -69,8 +70,10 @@ void __uClibc_main(main_t main,
        uClibc_main __start_main__;
 
        __start_main__ = dlsym(RTLD_NEXT, "__uClibc_main");
-       if (!__start_main__)
+       if (!__start_main__) {
                ERROR("failed to find __uClibc_main %s\n", dlerror());
+               return;
+       }
 
        __main__ = main;