From: Daniel Carl <danielcarl@gmx.de>
Date: Thu, 27 Nov 2014 21:16:42 +0000 (+0100)
Subject: Fixed wrong hsts protocol comparison (#146).
X-Git-Url: https://git.owens.tech/about.html/about.html/git?a=commitdiff_plain;h=279c46e6a2384017fe841bc46c4ce3a9844b5e3e;p=vimb.git

Fixed wrong hsts protocol comparison (#146).

The uri->scheme isn't a integer value like expected, so we have to use
strcmp() to compare it with the constant.
---

diff --git a/src/hsts.c b/src/hsts.c
index c05a1f5..ee2a8b5 100644
--- a/src/hsts.c
+++ b/src/hsts.c
@@ -102,7 +102,7 @@ char *hsts_get_changed_uri(SoupSession* session, SoupMessage *msg)
 
     provider = HSTS_PROVIDER(feature);
     /* if URI uses still https we don't nee to rewrite it */
-    if (uri->scheme != SOUP_URI_SCHEME_HTTPS
+    if (strcmp(uri->scheme, SOUP_URI_SCHEME_HTTPS)
         && should_secure_host(provider, uri->host)
     ) {
         /* the ports is set by soup uri if scheme is changed */
@@ -343,7 +343,7 @@ static void request_queued(SoupSessionFeature *feature,
     HSTSProvider *provider = HSTS_PROVIDER(feature);
 
     /* only look for HSTS headers sent over https RFC 6797 7.2*/
-    if (uri->scheme == SOUP_URI_SCHEME_HTTPS) {
+    if (!strcmp(uri->scheme, SOUP_URI_SCHEME_HTTPS)) {
         soup_message_add_header_handler(
             msg, "got-headers", HSTS_HEADER_NAME, G_CALLBACK(process_hsts_header), feature
         );
@@ -363,7 +363,7 @@ static void request_started(SoupSessionFeature *feature,
     GTlsCertificateFlags errors;
 
     if (should_secure_host(provider, uri->host)) {
-        if (uri->scheme != SOUP_URI_SCHEME_HTTPS
+        if (strcmp(uri->scheme, SOUP_URI_SCHEME_HTTPS)
             || (soup_message_get_https_status(msg, &certificate, &errors) && errors)
         ) {
             soup_session_cancel_message(session, msg, SOUP_STATUS_SSL_FAILED);