Browse Source

jail: preload: avoid NULL-dereference in case things go wrong

Coverity CID: 1446096 Dereference after null check
Coverity CID: 1446070 Dereference after null check

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle 2 years ago
parent
commit
b824a896ac
1 changed files with 6 additions and 2 deletions
  1. 6 2
      jail/preload.c

+ 6 - 2
jail/preload.c

@@ -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;