From 653be2dbdedf3b7b206d9dafe35e9bda5d6ff8be Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 18 Mar 2024 16:32:30 +0100 Subject: [PATCH] utils: use memmove when src and dst can overlap spa_json_parse_stringn() can be used when the strings source and destination are overlapping so use memmove instead of strncpy to avoid corruption of the strings. --- spa/include/spa/utils/json.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spa/include/spa/utils/json.h b/spa/include/spa/utils/json.h index c97e25371..de849b0c4 100644 --- a/spa/include/spa/utils/json.h +++ b/spa/include/spa/utils/json.h @@ -339,7 +339,7 @@ static inline int spa_json_parse_stringn(const char *val, int len, char *result, return -1; if (!spa_json_is_string(val, len)) { if (result != val) - strncpy(result, val, len); + memmove(result, val, len); result += len; } else { for (p = val+1; p < val + len; p++) {