From ef41f96ea518d1d164ea178f9364721b0a78e599 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 29 Sep 2018 11:10:45 +0200 Subject: [PATCH] value-variant.c: Avoid read from beyond end of buffer in string values. --- src/ui/gui/value-variant.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ui/gui/value-variant.c b/src/ui/gui/value-variant.c index 0789717ab7..ce523ae14e 100644 --- a/src/ui/gui/value-variant.c +++ b/src/ui/gui/value-variant.c @@ -87,12 +87,11 @@ value_variant_get (union value *val, GVariant *v) else { const gchar *data = g_variant_get_bytestring (vdata); + size_t len = strlen (data); if (width <= MAX_SHORT_STRING) - memcpy (val->short_string, data, MAX_SHORT_STRING); + memcpy (val->short_string, data, MIN (MAX_SHORT_STRING, len)); else - { - val->long_string = xmemdup (data, width); - } + val->long_string = xmemdup (data, MIN (width, len)); } g_variant_unref (vdata); -- 2.30.2