From 871ba6122819787e65633d0f0a8bdae7ab39c1f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 20 Dec 2021 20:14:31 +0100 Subject: [PATCH] spa: pod: parser: add null terminator If the supplied buffer has smaller (or equal) size than the length of the string, then `strncpy()` will not place a null terminator in the buffer. Fix that by always setting the last byte of the buffer to zero. --- spa/include/spa/pod/parser.h | 1 + 1 file changed, 1 insertion(+) diff --git a/spa/include/spa/pod/parser.h b/spa/include/spa/pod/parser.h index b6a36e6f5..c0a3099da 100644 --- a/spa/include/spa/pod/parser.h +++ b/spa/include/spa/pod/parser.h @@ -364,6 +364,7 @@ do { \ char *dest = va_arg(args, char*); \ uint32_t maxlen = va_arg(args, uint32_t); \ strncpy(dest, (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod), maxlen-1); \ + dest[maxlen-1] = '\0'; \ break; \ } \ case 'y': \