From 94540e7fd245b898ea697451cac2932d67395c30 Mon Sep 17 00:00:00 2001 From: Dmitry Kabanov Date: Thu, 21 Nov 2024 17:34:28 +0100 Subject: [PATCH] Fix buffer-overflow bug in oif_util_str_duplicate --- oif/lang_c/oif_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oif/lang_c/oif_util.c b/oif/lang_c/oif_util.c index 949e3394..caa00e51 100644 --- a/oif/lang_c/oif_util.c +++ b/oif/lang_c/oif_util.c @@ -24,7 +24,7 @@ char * oif_util_str_duplicate(const char *src) { size_t len = strlen(src); - char *dest = malloc(len * sizeof(*dest)); + char *dest = malloc((len + 1) * sizeof(*dest)); if (dest == NULL) { fprintf(stderr, "[str_duplicate] Could not allocate memory\n"); return NULL;