]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: use %u instead of %ld for port number printf
authorDaniel Stenberg <daniel@haxx.se>
Wed, 30 Jun 2021 10:56:22 +0000 (12:56 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 30 Jun 2021 21:25:35 +0000 (23:25 +0200)
Follow-up to 764c6bd3bf which changed the type of some port number
fields. Detected by Coverity (CID 1486624) etc.

Closes #7325

lib/connect.c
lib/url.c
lib/urlapi.c

index 18d3d84f5259a0d3039dc4f03613e3dff1dbb218..1875334d63d8c5402d875cd9f73a8329066629c5 100644 (file)
@@ -1038,7 +1038,7 @@ CURLcode Curl_is_connected(struct Curl_easy *data,
     else
       hostname = conn->host.name;
 
-    failf(data, "Failed to connect to %s port %ld after %ld ms: %s",
+    failf(data, "Failed to connect to %s port %u after %ld ms: %s",
         hostname, conn->port,
         Curl_timediff(now, data->progress.t_startsingle),
         Curl_strerror(error, buffer, sizeof(buffer)));
index a8208d749e4845e1efea778fbe78914a40cc189e..405499aff893c2ddb05384326a1f55b76a956d4e 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -1521,7 +1521,7 @@ void Curl_verboseconnect(struct Curl_easy *data,
                          struct connectdata *conn)
 {
   if(data->set.verbose)
-    infof(data, "Connected to %s (%s) port %ld (#%ld)\n",
+    infof(data, "Connected to %s (%s) port %u (#%ld)\n",
 #ifndef CURL_DISABLE_PROXY
           conn->bits.socksproxy ? conn->socks_proxy.host.dispname :
           conn->bits.httpproxy ? conn->http_proxy.host.dispname :
index d6d92cf777dcc162528142df5e9c118cdd827d73..905c499d995829dbdf3d1ae91db248a42dd77130 100644 (file)
@@ -1155,7 +1155,7 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what,
       const struct Curl_handler *h =
         Curl_builtin_scheme(u->scheme);
       if(h) {
-        msnprintf(portbuf, sizeof(portbuf), "%ld", h->defport);
+        msnprintf(portbuf, sizeof(portbuf), "%u", h->defport);
         ptr = portbuf;
       }
     }
@@ -1214,7 +1214,7 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what,
         /* there's no stored port number, but asked to deliver
            a default one for the scheme */
         if(h) {
-          msnprintf(portbuf, sizeof(portbuf), "%ld", h->defport);
+          msnprintf(portbuf, sizeof(portbuf), "%u", h->defport);
           port = portbuf;
         }
       }