[hackers] [sbase] sbase-box: Fix segmentation fault when exe without args

From: Jules Maselbas <jmaselbas_AT_zdiv.net>
Date: Fri, 1 Dec 2023 13:33:36 +0100

when sbase-box is executed without argument, the check sbase-box
options doesn't verify the argument count leading to a segfault.

Add a check on the argc before parsing sbase-box options (currently
only `-i`)

---
 scripts/mkbox | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/mkbox b/scripts/mkbox
index b9e9bb0..db2bdb9 100755
--- a/scripts/mkbox
+++ b/scripts/mkbox
_AT_@ -76,7 +76,7 @@ main(int argc, char *argv[])
 	char *s = basename(argv[0]);
 	struct cmd *bp;
 
-	if(!strcmp(s,"sbase-box")) {
+	if (!strcmp(s, "sbase-box") && argc > 1) {
 		argc--; argv++;
 		if (strcmp(argv[0], "-i") == 0) {
 			install(argv[1]);
-- 
2.42.1
Received on Fri Dec 01 2023 - 13:33:36 CET

This archive was generated by hypermail 2.3.0 : Fri Dec 01 2023 - 13:36:35 CET