core-util: Handle zero-length volume string

Without checking for zero we end up accessing memory outside the str
buffer: str[len - 1].

Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/768
This commit is contained in:
Tanu Kaskinen 2019-12-27 07:33:52 +02:00
parent cd4a69374c
commit 4dba56c1af

View file

@ -879,7 +879,7 @@ int pa_parse_volume(const char *v, pa_volume_t *volume) {
len = strlen(v); len = strlen(v);
if (len >= 64) if (len <= 0 || len >= 64)
return -1; return -1;
memcpy(str, v, len + 1); memcpy(str, v, len + 1);