Skip to contentSkip to conversation

handle potential strdup failure

PATCH Applied Ilia Shipitsin 2 participants 3 messages Nov 18, 2024 – May 21, 2025

lore
Share & tools
lore
#0 lore raw

cover handle potential strdup failure

if allocation fails, strdup returns NULL.

Ilia Shipitsin (1):
src/config.c: handle strdup failure

 src/config.c | 6 ++++++
 1 file changed, 6 insertions(+)
Signature · 1 line
2.43.0.windows.1
#1 lore raw

PATCH 1/1 src/config.c: handle strdup failure

---
 src/config.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/config.c +6 -0
index 81ccb47..f78e076 100644
@@ -357,6 +357,12 @@ static inline bool parse_allowedips(struct wgpeer *peer, struct wgallowedip **la
 		char *end, *ip;
 
 		saved_entry = strdup(mask);
+		if (!saved_entry) {
+			perror("strdup");
+			free(mutable);
+			return false;
+		}
+
 		ip = strsep(&mask, "/");
 
 		new_allowedip = calloc(1, sizeof(*new_allowedip));
Signature · 1 line
2.43.0.windows.1
#2 lore raw

Re: [PATCH 1/1] src/config.c: handle strdup failure

Applied, thanks for the patch.