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.
This commit is contained in:
Barnabás Pőcze 2021-12-20 20:14:31 +01:00
parent b04b52ecf8
commit 871ba61228

View file

@ -364,6 +364,7 @@ do { \
char *dest = va_arg(args, char*); \ char *dest = va_arg(args, char*); \
uint32_t maxlen = va_arg(args, uint32_t); \ uint32_t maxlen = va_arg(args, uint32_t); \
strncpy(dest, (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod), maxlen-1); \ strncpy(dest, (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod), maxlen-1); \
dest[maxlen-1] = '\0'; \
break; \ break; \
} \ } \
case 'y': \ case 'y': \