mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-07 13:30:07 -05:00
fix buffer overflows
Signed-off-by: Benjamin Otte <in7y118@public.uni-hamburg.de>
This commit is contained in:
parent
6627bd5273
commit
f3fff3e0ef
1 changed files with 5 additions and 2 deletions
|
|
@ -255,7 +255,9 @@ static int snd_output_buffer_need(snd_output_t *output, size_t size)
|
|||
if (buffer->alloc == 0)
|
||||
alloc = 256;
|
||||
else
|
||||
alloc = buffer->alloc * 2;
|
||||
alloc = buffer->alloc;
|
||||
while (alloc < size)
|
||||
alloc *= 2;
|
||||
buffer->buf = realloc(buffer->buf, alloc);
|
||||
if (!buffer->buf)
|
||||
return -ENOMEM;
|
||||
|
|
@ -281,8 +283,9 @@ static int snd_output_buffer_print(snd_output_t *output, const char *format, va_
|
|||
result = snd_output_buffer_need(output, size);
|
||||
if (result < 0)
|
||||
return result;
|
||||
result = vsprintf(buffer->buf + buffer->size, format, args);
|
||||
result = vsnprintf(buffer->buf + buffer->size, result, format, args);
|
||||
assert(result == (int)size);
|
||||
buffer->size += result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue