]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl: show better error message when no homedir is found
authorDaniel Stenberg <daniel@haxx.se>
Mon, 2 Dec 2019 11:00:41 +0000 (12:00 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 3 Dec 2019 15:26:02 +0000 (16:26 +0100)
Reported-by: Vlastimil Ovčáčík
Fixes #4644
Closes #4665

src/tool_msgs.c
src/tool_msgs.h
src/tool_operate.c

index 48c7249403572f092b641ab2068a9590a5ed37e3..c0e85aee6e3818ad58f8dec0a2609f9400940155 100644 (file)
@@ -32,6 +32,7 @@
 
 #define WARN_PREFIX "Warning: "
 #define NOTE_PREFIX "Note: "
+#define ERROR_PREFIX "curl: "
 
 static void voutf(struct GlobalConfig *config,
                   const char *prefix,
@@ -122,3 +123,16 @@ void helpf(FILE *errors, const char *fmt, ...)
 #endif
           "for more information\n");
 }
+
+/*
+ * Emit error message on error stream if not muted.
+ */
+void errorf(struct GlobalConfig *config, const char *fmt, ...)
+{
+  if(!config->mute) {
+    va_list ap;
+    va_start(ap, fmt);
+    voutf(config, ERROR_PREFIX, fmt, ap);
+    va_end(ap);
+  }
+}
index bd8480d30ec8236304526a9e3964b4ccb9e07cce..2c4afd18062ddee265b2a15af361bba3fd1167e1 100644 (file)
@@ -25,7 +25,7 @@
 
 void warnf(struct GlobalConfig *config, const char *fmt, ...);
 void notef(struct GlobalConfig *config, const char *fmt, ...);
-
 void helpf(FILE *errors, const char *fmt, ...);
+void errorf(struct GlobalConfig *config, const char *fmt, ...);
 
 #endif /* HEADER_CURL_TOOL_MSGS_H */
index 23971f1128c25f080c1208bf36fe4a323aef7d7b..ab3a7f1a0906f908895ae8002d4d4f7cdaf8a0db 100644 (file)
@@ -1615,7 +1615,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
           if(!config->insecure_ok) {
             char *home;
             char *file;
-            result = CURLE_OUT_OF_MEMORY;
+            result = CURLE_FAILED_INIT;
             home = homedir();
             if(home) {
               file = aprintf("%s/.ssh/known_hosts", home);
@@ -1629,6 +1629,9 @@ static CURLcode single_transfer(struct GlobalConfig *global,
               }
               Curl_safefree(home);
             }
+            else {
+              errorf(global, "Failed to figure out user's home dir!");
+            }
             if(result)
               break;
           }