tools: replace strcpy with memcpy

Potential buffer overflow in metadata_property function when copying strings.

Fixes buffer overflow issue in string copying.
This commit is contained in:
ctf 2026-04-16 09:31:37 +08:00
parent b445e82bcb
commit ee5505430e

View file

@ -1107,12 +1107,12 @@ static int metadata_property(void *data,
e->subject = subject;
e->key = SPA_PTROFF(e, sizeof(*e), void);
strcpy(e->key, key);
e->value = SPA_PTROFF(e->key, strlen(e->key) + 1, void);
strcpy(e->value, value);
memcpy(e->key, key, strlen(key) + 1);
e->value = SPA_PTROFF(e->key, strlen(key) + 1, void);
memcpy(e->value, value, strlen(value) + 1);
if (type) {
e->type = SPA_PTROFF(e->value, strlen(e->value) + 1, void);
strcpy(e->type, type);
e->type = SPA_PTROFF(e->value, strlen(value) + 1, void);
memcpy(e->type, type, strlen(type) + 1);
} else {
e->type = NULL;
}