mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-10-14 20:02:38 +00:00
spa: don't overrun the input array
Read one byte less than the size of the buffer so that we still have room in the buffer to append the 0 byte.
This commit is contained in:
parent
d2d01b43d3
commit
f95ecf95ba
|
@ -63,11 +63,11 @@ static char *read_file(const char *name, char *buffer, size_t len)
|
|||
if ((fd = open(name, O_RDONLY | O_CLOEXEC, 0)) < 0)
|
||||
return NULL;
|
||||
|
||||
if ((n = read(fd, buffer, len)) < 0) {
|
||||
if ((n = read(fd, buffer, len-1)) < 0) {
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
buffer[n] = 0;
|
||||
buffer[n] = '\0';
|
||||
close(fd);
|
||||
return buffer;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue