mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-21 06:46:38 -04:00
conf: clamp pw_strv_insert_at invalid pos to [0, len]
Invalid pos was clamped to len+1, which could insert past the terminating NULL. Clamp negative indices to 0 and values above len to len.
This commit is contained in:
parent
f0a33cddbd
commit
0a38fedeec
1 changed files with 5 additions and 2 deletions
|
|
@ -918,8 +918,11 @@ static char **pw_strv_insert_at(char **strv, int len, int pos, const char *str)
|
||||||
while (strv != NULL && strv[len] != NULL)
|
while (strv != NULL && strv[len] != NULL)
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
if (pos < 0 || pos > len)
|
|
||||||
pos = len+1;
|
if (pos < 0)
|
||||||
|
pos = 0;
|
||||||
|
else if (pos > len)
|
||||||
|
pos = len;
|
||||||
|
|
||||||
n = realloc(strv, sizeof(char*) * (len + 2));
|
n = realloc(strv, sizeof(char*) * (len + 2));
|
||||||
if (n == NULL) {
|
if (n == NULL) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue