jail: preload: avoid NULL-dereference in case things go wrong
authorDaniel Golle <daniel@makrotopia.org>
Mon, 23 Aug 2021 17:15:20 +0000 (18:15 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 24 Aug 2021 17:32:06 +0000 (18:32 +0100)
Coverity CID: 1446096 Dereference after null check
Coverity CID: 1446070 Dereference after null check

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
jail/preload.c

index 9678ab6e9c24c83f0384035db8e726b27f6018b5..351a9f81368bfd563c83e1a0e06409385dbe99de 100644 (file)
@@ -62,8 +62,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__) {
                INFO("failed to find __libc_start_main %s\n", dlerror());
+               return -1;
+       }
 
        __main__ = main;
 
@@ -82,8 +84,10 @@ void __uClibc_main(main_t main,
        uClibc_main __start_main__;
 
        __start_main__ = dlsym(RTLD_NEXT, "__uClibc_main");
-       if (!__start_main__)
+       if (!__start_main__) {
                INFO("failed to find __uClibc_main %s\n", dlerror());
+               return;
+       }
 
        __main__ = main;