richardphibel / rpms / systemd

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