Fixed wrong hsts protocol comparison (#146).
authorDaniel Carl <danielcarl@gmx.de>
Thu, 27 Nov 2014 21:16:42 +0000 (22:16 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Thu, 27 Nov 2014 21:25:33 +0000 (22:25 +0100)
The uri->scheme isn't a integer value like expected, so we have to use
strcmp() to compare it with the constant.

src/hsts.c

index c05a1f5..ee2a8b5 100644 (file)
@@ -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);