Skip to content
Snippets Groups Projects
Commit 52b63137 authored by Guillem Jover's avatar Guillem Jover
Browse files

libdpkg: Fix undefined behavior in varbuf functions


While varbuf_grow() handles 0 sizes fine, we do a check before calling
it to avoid the duplicate checks.

Reported-by: default avatarKOLANICH <kolan_n@mail.ru>
Warned-by: gcc ASAN
parent 7d2d5be9
No related branches found
No related tags found
1 merge request!3Update to 1.20.9pureos1
......@@ -40,6 +40,8 @@ varbuf_add_char(struct varbuf *v, int c)
void
varbuf_dup_char(struct varbuf *v, int c, size_t n)
{
if (n == 0)
return;
varbuf_grow(v, n);
memset(v->buf + v->used, c, n);
v->used += n;
......@@ -95,6 +97,8 @@ varbuf_vprintf(struct varbuf *v, const char *fmt, va_list args)
void
varbuf_add_buf(struct varbuf *v, const void *s, size_t size)
{
if (size == 0)
return;
varbuf_grow(v, size);
memcpy(v->buf + v->used, s, size);
v->used += size;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment