30 lines
744 B
Diff
30 lines
744 B
Diff
|
|
From dbfd84301a9316018f7c5e42ff5b3a19dd13e5c5 Mon Sep 17 00:00:00 2001
|
||
|
|
From: modric <pioneerbtw7@163.com>
|
||
|
|
Date: Tue, 22 Nov 2022 10:12:29 +0800
|
||
|
|
Subject: [PATCH] sudo_rcstr_dup: Fix potential NULL pointer deref
|
||
|
|
|
||
|
|
---
|
||
|
|
lib/util/rcstr.c | 6 ++++--
|
||
|
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/lib/util/rcstr.c b/lib/util/rcstr.c
|
||
|
|
index d990a99e9..08b00bcd7 100644
|
||
|
|
--- a/lib/util/rcstr.c
|
||
|
|
+++ b/lib/util/rcstr.c
|
||
|
|
@@ -49,8 +49,10 @@ sudo_rcstr_dup(const char *src)
|
||
|
|
debug_decl(sudo_rcstr_dup, SUDO_DEBUG_UTIL);
|
||
|
|
|
||
|
|
dst = sudo_rcstr_alloc(len);
|
||
|
|
- memcpy(dst, src, len);
|
||
|
|
- dst[len] = '\0';
|
||
|
|
+ if (dst != NULL) {
|
||
|
|
+ memcpy(dst, src, len);
|
||
|
|
+ dst[len] = '\0';
|
||
|
|
+ }
|
||
|
|
debug_return_ptr(dst);
|
||
|
|
}
|
||
|
|
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|