mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
Avoid crash in virBufferEscapeString
* src/util/buf.c: if virBufferEscapeString was called on a buffer that had 0 bytes of space, a size of -1 will be passed to snprintf, resulting in a segmentation fault, this preallocate some space.
This commit is contained in:
parent
e391595890
commit
04e0686262
@ -318,6 +318,12 @@ virBufferEscapeString(const virBufferPtr buf, const char *format, const char *st
|
||||
}
|
||||
*out = 0;
|
||||
|
||||
if ((buf->use >= buf->size) &&
|
||||
virBufferGrow(buf, 100) < 0) {
|
||||
VIR_FREE(escaped);
|
||||
return;
|
||||
}
|
||||
|
||||
size = buf->size - buf->use - 1;
|
||||
while (((count = snprintf(&buf->content[buf->use], size, format,
|
||||
(char *)escaped)) < 0) || (count >= size - 1)) {
|
||||
|
Loading…
Reference in New Issue
Block a user