You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
systemd/SOURCES/0065-shared-be-extra-parano...

28 lines
1.1 KiB

From 83845c85669084c4cd69fa8bfe60c57d36bb8713 Mon Sep 17 00:00:00 2001
From: Frantisek Sumsal <frantisek@sumsal.cz>
Date: Fri, 28 Jan 2022 21:44:32 +0100
Subject: [PATCH] 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.
(cherry picked from commit 1637e757070a61b12b26a2a4ef547330562dc77f)
Related: #2017035
---
src/shared/main-func.h | 1 +
1 file changed, 1 insertion(+)
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; \