From c4f895d86b2359206afb8ab0acfc0f748de95eb8 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 27 Jan 2022 12:02:27 +0100 Subject: [PATCH] Do not crash when run with argc == 0 --- suidgw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/suidgw.c b/suidgw.c index 47885f6..43e3394 100644 --- a/suidgw.c +++ b/suidgw.c @@ -1,7 +1,7 @@ /* * A simple gateway for set-uid scripts * - * (c) 2013 Martin Mares + * (c) 2013-2022 Martin Mares */ #undef DEBUG @@ -85,6 +85,9 @@ static void sanitize_env(void) static void get_script_name(const char *arg0) { + if (!arg0) + die("Program name must be given"); + // If arg0 is a path, extract the last component const char *p = strrchr(arg0, '/'); if (p) -- 2.39.2