]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl: output warning at --verbose output for debug-enabled version
authorDaniel Stenberg <daniel@haxx.se>
Wed, 11 Jan 2023 13:15:26 +0000 (14:15 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 12 Jan 2023 16:59:26 +0000 (17:59 +0100)
+ a libcurl warning in the debug output

Assisted-by: Jay Satiro
Ref: https://curl.se/mail/lib-2023-01/0039.html
Closes #10278

lib/multi.c
lib/multihandle.h
src/tool_help.c

index b6187cd20f0113ba4bd3b5931501d7d7be85541f..403274814b51fa65028db2bd82a516061052424f 100644 (file)
@@ -1861,6 +1861,15 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
     multistate(data, MSTATE_COMPLETED);
   }
 
+#ifdef DEBUGBUILD
+  if(!multi->warned) {
+    infof(data, "!!! WARNING !!!");
+    infof(data, "This is a debug build of libcurl, "
+          "do not use in production.");
+    multi->warned = true;
+  }
+#endif
+
   do {
     /* A "stream" here is a logical stream if the protocol can handle that
        (HTTP/2), or the full connection for older protocols */
index 7dd6a0a75d6e612ce2064543a5e957b94de4c4de..6cda65d442227c6e63221e37511899bfea261a8b 100644 (file)
@@ -170,6 +170,9 @@ struct Curl_multi {
 #endif
   BIT(dead); /* a callback returned error, everything needs to crash and
                 burn */
+#ifdef DEBUGBUILD
+  BIT(warned);                 /* true after user warned of DEBUGBUILD */
+#endif
 };
 
 #endif /* HEADER_CURL_MULTIHANDLE_H */
index 709b8fefb73c93ac79fd1ad1fc0c01262d0870c6..729b78c366e1b9fc35b52c10d4ebf0e95b4dc2b9 100644 (file)
@@ -151,10 +151,21 @@ void tool_help(char *category)
   free(category);
 }
 
+static bool is_debug(void)
+{
+  const char *const *builtin;
+  for(builtin = feature_names; *builtin; ++builtin)
+    if(curl_strequal("debug", *builtin))
+      return TRUE;
+  return FALSE;
+}
 
 void tool_version_info(void)
 {
   const char *const *builtin;
+  if(is_debug())
+    fprintf(stderr, "WARNING: this libcurl is Debug-enabled, "
+            "do not use in production\n\n");
 
   printf(CURL_ID "%s\n", curl_version());
 #ifdef CURL_PATCHSTAMP