Skip to content

Commit c3d05b0

Browse files
dfandrichbch
authored andcommitted
tool_operate: Fix error codes during DOS filename sanitize
It would return CURLE_URL_MALFORMAT in an OOM condition. Closes curl#10414
1 parent 1d58eb0 commit c3d05b0

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/tool_operhlp.c

+11-8
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,17 @@ CURLcode get_url_file_name(char **filename, const char *url)
209209
return CURLE_OUT_OF_MEMORY;
210210

211211
#if defined(MSDOS) || defined(WIN32)
212-
{
213-
char *sanitized;
214-
SANITIZEcode sc = sanitize_file_name(&sanitized, *filename, 0);
215-
Curl_safefree(*filename);
216-
if(sc)
217-
return CURLE_URL_MALFORMAT;
218-
*filename = sanitized;
219-
}
212+
{
213+
char *sanitized;
214+
SANITIZEcode sc = sanitize_file_name(&sanitized, *filename, 0);
215+
Curl_safefree(*filename);
216+
if(sc) {
217+
if(sc == SANITIZE_ERR_OUT_OF_MEMORY)
218+
return CURLE_OUT_OF_MEMORY;
219+
return CURLE_URL_MALFORMAT;
220+
}
221+
*filename = sanitized;
222+
}
220223
#endif /* MSDOS || WIN32 */
221224

222225
/* in case we built debug enabled, we allow an environment variable

0 commit comments

Comments
 (0)