[libsoup/wip/fuzzing: 2/3] Fix minor issue found by fuzzing



commit b243773c0ee287c659c4a5692fb1613b1048ec17
Author: Patrick Griffis <pgriffis igalia com>
Date:   Tue Dec 15 17:42:57 2020 -0600

    Fix minor issue found by fuzzing

 libsoup/soup-uri-utils.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/libsoup/soup-uri-utils.c b/libsoup/soup-uri-utils.c
index dc1afd23..a39bb24d 100644
--- a/libsoup/soup-uri-utils.c
+++ b/libsoup/soup-uri-utils.c
@@ -344,11 +344,15 @@ soup_uri_decode_data_uri (const char *uri,
                 bytes = g_uri_unescape_bytes (start, -1, NULL, NULL);
 
                 if (base64 && bytes) {
-                        gsize content_length;
-                        GByteArray *unescaped_array = g_bytes_unref_to_array (bytes);
-                        g_base64_decode_inplace ((gchar*)unescaped_array->data, &content_length);
-                        unescaped_array->len = content_length;
-                        bytes = g_byte_array_free_to_bytes (unescaped_array);
+                        if (g_bytes_get_size (bytes) <= 1)
+                                g_clear_pointer (&bytes, g_bytes_unref);
+                        else {
+                                gsize content_length;
+                                GByteArray *unescaped_array = g_bytes_unref_to_array (bytes);
+                                g_base64_decode_inplace ((gchar*)unescaped_array->data, &content_length);
+                                unescaped_array->len = content_length;
+                                bytes = g_byte_array_free_to_bytes (unescaped_array);
+                        }
                 }
         } else {
                 bytes = g_bytes_new_static (NULL, 0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]