← Commit list

7ab9018ea7

Daniel Stenberg
Daniel Stenberg
2025-10-09
SUCCESS Duration: 203s

Subject

mk-lib1521: verify the setopt options that accept -1

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

tests/libtest/mk-lib1521.pl+30 -0
@@ -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") {