[spice-common 1/2] ssl-verify: Handle NULL return from g_inet_address_new_from_string()

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

 



It will return NULL if the string we pass it cannot be parsed.
---
 common/ssl_verify.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/common/ssl_verify.c b/common/ssl_verify.c
index 867c54f..817cf7b 100644
--- a/common/ssl_verify.c
+++ b/common/ssl_verify.c
@@ -200,8 +200,12 @@ static int verify_hostname(X509* cert, const char *hostname)
                 found_dns_name = 1;
 
                 ip = g_inet_address_new_from_string(hostname);
-                ip_len = g_inet_address_get_native_size(ip);
-                ip_binary = g_inet_address_to_bytes(ip);
+                if (ip != NULL) {
+                    ip_len = g_inet_address_get_native_size(ip);
+                    ip_binary = g_inet_address_to_bytes(ip);
+                } else {
+                    spice_warning("Could not parse hostname: %s", hostname);
+                }
 
                 alt_ip_len = ASN1_STRING_length(name->d.iPAddress);
 
-- 
2.5.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]