8d419f
From c134e85526f160ad4392edb333caadc5e425957d Mon Sep 17 00:00:00 2001
8d419f
From: Lennart Poettering <lennart@poettering.net>
8d419f
Date: Tue, 1 Feb 2022 12:06:21 +0100
8d419f
Subject: [PATCH] util: another set of CVE-2021-4034 assert()s
8d419f
8d419f
It's a good idea that we validate argc/argv when we are supposed to
8d419f
store them away.
8d419f
8d419f
(cherry picked from commit 007e03b284e8ffc0b92edb2122cd9d2d16f049ef)
8d419f
8d419f
Related: #2017035
8d419f
---
8d419f
 src/basic/util.h | 6 ++++++
8d419f
 1 file changed, 6 insertions(+)
8d419f
8d419f
diff --git a/src/basic/util.h b/src/basic/util.h
8d419f
index 94804f28e3..68ae3b51e0 100644
8d419f
--- a/src/basic/util.h
8d419f
+++ b/src/basic/util.h
8d419f
@@ -9,6 +9,12 @@ extern int saved_argc;
8d419f
 extern char **saved_argv;
8d419f
 
8d419f
 static inline void save_argc_argv(int argc, char **argv) {
8d419f
+
8d419f
+        /* Protect against CVE-2021-4034 style attacks */
8d419f
+        assert_se(argc > 0);
8d419f
+        assert_se(argv);
8d419f
+        assert_se(argv[0]);
8d419f
+
8d419f
         saved_argc = argc;
8d419f
         saved_argv = argv;
8d419f
 }