]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mk-lib1521: verify the setopt options that accept -1
authorDaniel Stenberg <daniel@haxx.se>
Thu, 9 Oct 2025 08:15:41 +0000 (10:15 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 9 Oct 2025 08:42:40 +0000 (10:42 +0200)
tests/libtest/mk-lib1521.pl

index e0a7d157d8832d6c898060853f66ebb24b330b26..95a600c3d02ae6e0edc580acadc31121446bd1ec 100755 (executable)
@@ -255,6 +255,12 @@ $allowednumerrors
                name, code, curl_easy_strerror(code), lineno);
 }
 
+static void errneg(const char *name, CURLcode code, int lineno)
+{
+  curl_mprintf("%s set to -1 returned %d, \\"%s\\" on line %d\\n",
+               name, code, curl_easy_strerror(code), lineno);
+}
+
 static void errstring(const char *name, CURLcode code, int lineno)
 {
   /* allow this set of options to return CURLE_BAD_FUNCTION_ARGUMENT
@@ -322,6 +328,23 @@ static bool bad_long(CURLcode res, int check)
   return 0;
 }
 
+/* long options that should handle -1 */
+static bool bad_neg(int check)
+{
+  switch(check) {
+    case CURLOPT_DNS_CACHE_TIMEOUT:
+    case CURLOPT_INFILESIZE:
+    case CURLOPT_INFILESIZE_LARGE:
+    case CURLOPT_MAXREDIRS:
+    case CURLOPT_POSTFIELDSIZE:
+    case CURLOPT_POSTFIELDSIZE_LARGE:
+    case CURLOPT_RESUME_FROM:
+    case CURLOPT_RESUME_FROM_LARGE:
+      return TRUE;
+  }
+  return FALSE;
+}
+
 /* macro to check the first setopt of an option which then is allowed to get a
    non-existing function return code back */
 #define present(x) ((x != CURLE_NOT_BUILT_IN) && (x != CURLE_UNKNOWN_OPTION))
@@ -456,6 +479,12 @@ MOO
 MOO
             ;
 
+        my $negcheck = <<MOO
+      if(res && bad_neg($name))
+        errneg("$name", res, __LINE__);
+MOO
+            ;
+
         my $nullcheck = <<MOO
       if(res)
         errnull(\"$name\", res, __LINE__);
@@ -474,6 +503,7 @@ MOO
             print $fh "$ifpresent";
             print $fh "${pref} 22L);\n$longcheck";
             print $fh "${pref} LO);\n$longcheck";
+            print $fh "${pref} -1L);\n$negcheck";
             print $fh "${pref} HI);\n$longcheck";
         }
         elsif($type eq "CURLOPTTYPE_OFF_T") {