[libsoup] Handle potential g_uri_unescape_string failures



commit d93656501daf47dcf33e6371764e0f6fa6095134
Author: Patrick Griffis <pgriffis igalia com>
Date:   Fri Jan 28 10:53:49 2022 -0600

    Handle potential g_uri_unescape_string failures
    
    It is possible that unescaping fails so use g_strcmp0() which
    is NULL safe or report that decoding failed.

 libsoup/server/soup-auth-domain-digest.c | 2 +-
 libsoup/soup-headers.c                   | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/libsoup/server/soup-auth-domain-digest.c b/libsoup/server/soup-auth-domain-digest.c
index 4011babf..3a63bc4f 100644
--- a/libsoup/server/soup-auth-domain-digest.c
+++ b/libsoup/server/soup-auth-domain-digest.c
@@ -237,7 +237,7 @@ check_hex_urp (SoupAuthDomain    *domain,
                req_path = soup_uri_get_path_and_query (req_uri);
                dig_path = g_uri_unescape_string (uri, NULL);
 
-               if (strcmp (dig_path, req_path) != 0) {
+               if (g_strcmp0 (dig_path, req_path) != 0) {
                        g_free (req_path);
                        g_free (dig_path);
                        return FALSE;
diff --git a/libsoup/soup-headers.c b/libsoup/soup-headers.c
index fccd0ea9..5485e623 100644
--- a/libsoup/soup-headers.c
+++ b/libsoup/soup-headers.c
@@ -697,6 +697,9 @@ decode_rfc5987 (char *encoded_string)
                return FALSE;
 
        decoded = g_uri_unescape_string (q + 1, NULL);
+       if (decoded == NULL)
+               return FALSE;
+
        if (iso_8859_1) {
                char *utf8 =  g_convert_with_fallback (decoded, -1, "UTF-8",
                                                       "iso-8859-1", "_",


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