]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
hsts: explicitly skip blank lines
authorDaniel Gustafsson <daniel@yesql.se>
Tue, 14 May 2024 08:19:41 +0000 (10:19 +0200)
committerDaniel Gustafsson <daniel@yesql.se>
Tue, 14 May 2024 08:19:41 +0000 (10:19 +0200)
Keep blank lines or lines containing only whitespace to make it all
the way to the more expensive sscanf call in hsts_add.

Closes: #13603
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
lib/hsts.c

index 72b80a46ca237dd39de17a9b89725a29a517d54c..a5e7676138cd8c8d07ed187ac09e3bd1797acd49 100644 (file)
@@ -523,8 +523,11 @@ static CURLcode hsts_load(struct hsts *h, const char *file)
       char *lineptr = Curl_dyn_ptr(&buf);
       while(*lineptr && ISBLANK(*lineptr))
         lineptr++;
-      if(*lineptr == '#')
-        /* skip commented lines */
+      /*
+       * Skip empty or commented lines, since we know the line will have a
+       * trailing newline from Curl_get_line we can treat length 1 as empty.
+       */
+      if((*lineptr == '#') || strlen(lineptr) <= 1)
         continue;
 
       hsts_add(h, lineptr);