summaryrefslogtreecommitdiffstats
path: root/src/shared/main-func.h
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2022-01-28 21:44:32 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-01-30 09:53:10 +0100
commit1637e757070a61b12b26a2a4ef547330562dc77f (patch)
tree5f7f8187d5300eb9758896bc723af79b948bf93e /src/shared/main-func.h
parentMerge pull request #22301 from mrc0mmand/cocci-tweaks (diff)
downloadsystemd-1637e757070a61b12b26a2a4ef547330562dc77f.tar.xz
systemd-1637e757070a61b12b26a2a4ef547330562dc77f.zip
shared: be extra paranoid and check if argc > 0
and also if argv[0] is non-empty as a precaution for issues similar to CVE-2021-4034.
Diffstat (limited to 'src/shared/main-func.h')
-rw-r--r--src/shared/main-func.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/shared/main-func.h b/src/shared/main-func.h
index 05cdffeec0..09103bace9 100644
--- a/src/shared/main-func.h
+++ b/src/shared/main-func.h
@@ -15,6 +15,7 @@
#define _DEFINE_MAIN_FUNCTION(intro, impl, ret) \
int main(int argc, char *argv[]) { \
int r; \
+ assert(argc > 0 && !isempty(argv[0])); \
save_argc_argv(argc, argv); \
intro; \
r = impl; \