]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl: make the URL indexes 64 bit
authorDaniel Stenberg <daniel@haxx.se>
Wed, 30 Jul 2025 09:20:45 +0000 (11:20 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 30 Jul 2025 21:13:45 +0000 (23:13 +0200)
Otherwise we could misbehave already at 2 billion URLs and we can't have
that. A few of the counters are already correctly using the right type.

Closes #18096

src/tool_operate.c
src/tool_operate.h
src/tool_sdecls.h
src/tool_writeout.c

index 1158d857363b2356a601f8a1dbc1d07f6b8c8ac2..17e1c1cf966361de99e01a3a94f6656435635f58 100644 (file)
@@ -1250,7 +1250,7 @@ static CURLcode single_transfer(struct OperationConfig *config,
       }
       per->config = config;
       per->curl = curl;
-      per->urlnum = (unsigned int)u->num;
+      per->urlnum = u->num;
 
       /* default headers output stream is stdout */
       heads = &per->heads;
index e7c972d61d1186a97a91f093b0aa8f6a1a0c16c5..2fe49931c17867b9ae0447eb204378ec0c785631 100644 (file)
@@ -42,7 +42,7 @@ struct per_transfer {
   struct curltime start; /* start of this transfer */
   struct curltime retrystart;
   char *url;
-  unsigned int urlnum; /* the index of the given URL */
+  curl_off_t urlnum; /* the index of the given URL */
   char *outfile;
   int infd;
   struct ProgressData progressbar;
index 3b01f5592ad89e18e392342f26f08e37fdc691e1..45b7bd0c20568f1bd6f497b44bf0dcb45ab513d2 100644 (file)
@@ -88,7 +88,7 @@ struct getout {
   char          *url;       /* the URL we deal with */
   char          *outfile;   /* where to store the output */
   char          *infile;    /* file to upload, if GETOUT_UPLOAD is set */
-  int            num;       /* which URL number in an invocation */
+  curl_off_t    num;        /* which URL number in an invocation */
 
   BIT(outset);    /* when outfile is set */
   BIT(urlset);    /* when URL is set */
index d348714299bfbb2767b0a481e7619c2b3c25fe12..dd69e3bd0239f31ebb12c9b7a520f71b8d91e886 100644 (file)
@@ -148,7 +148,7 @@ static const struct writeoutvar variables[] = {
   {"urle.scheme", VAR_INPUT_URLESCHEME, CURLINFO_NONE, writeString},
   {"urle.user", VAR_INPUT_URLEUSER, CURLINFO_NONE, writeString},
   {"urle.zoneid", VAR_INPUT_URLEZONEID, CURLINFO_NONE, writeString},
-  {"urlnum", VAR_URLNUM, CURLINFO_NONE, writeLong},
+  {"urlnum", VAR_URLNUM, CURLINFO_NONE, writeOffset},
   {"xfer_id", VAR_EASY_ID, CURLINFO_XFER_ID, writeOffset}
 };
 
@@ -462,12 +462,6 @@ static int writeLong(FILE *stream, const struct writeoutvar *wovar,
       longinfo = (long)per_result;
       valid = true;
       break;
-    case VAR_URLNUM:
-      if(per->urlnum <= INT_MAX) {
-        longinfo = (long)per->urlnum;
-        valid = true;
-      }
-      break;
     default:
       DEBUGASSERT(0);
       break;
@@ -508,7 +502,16 @@ static int writeOffset(FILE *stream, const struct writeoutvar *wovar,
       valid = true;
   }
   else {
-    DEBUGASSERT(0);
+    switch(wovar->id) {
+    case VAR_URLNUM:
+      if(per->urlnum <= INT_MAX) {
+        offinfo = per->urlnum;
+        valid = true;
+      }
+      break;
+    default:
+      DEBUGASSERT(0);
+    }
   }
 
   if(valid) {