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 3238ba0e2f
commit d9fc432872

View file

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