]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_urlglob: fix propagating OOM error from `sanitize_file_name()`
authorViktor Szakats <commit@vsz.me>
Tue, 6 Jan 2026 18:34:53 +0000 (19:34 +0100)
committerViktor Szakats <commit@vsz.me>
Tue, 6 Jan 2026 19:02:55 +0000 (20:02 +0100)
Make sure to convert a low-level OOM error code a libcurl one, to make
the curl tool to display an accurate error code and messages. On Windows
and MS-DOS.

Improving:
```
$ CURL_FN_SANITIZE_OOM=1 wine curl.exe https://curl.se/ --output out.txt
[...]
curl: (3) URL using bad/illegal format or missing URL
```
to:
```
[...]
curl: (27) Out of memory
```

Cherry-picked from #20116
Closes #20198

src/tool_urlglob.c

index bd03c9e6dc5cf5ea42ceebd9af197652ecbb68bb..7a0e15320f0d9d45603e0fed7761efa00bd5f262 100644 (file)
@@ -704,8 +704,11 @@ CURLcode glob_match_url(char **output, const char *filename,
                                          (SANITIZE_ALLOW_PATH |
                                           SANITIZE_ALLOW_RESERVED));
     curlx_dyn_free(&dyn);
-    if(sc)
+    if(sc) {
+      if(sc == SANITIZE_ERR_OUT_OF_MEMORY)
+        return CURLE_OUT_OF_MEMORY;
       return CURLE_URL_MALFORMAT;
+    }
     *output = sanitized;
     return CURLE_OK;
   }