2016-02-05 14:44:27 +08:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2020-05-29 03:51:25 +08:00
|
|
|
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2016-02-05 14:44:27 +08:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
* are also available at https://curl.se/docs/copyright.html.
|
2016-02-05 14:44:27 +08:00
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
#include "curlcheck.h"
|
|
|
|
|
|
|
|
#include "tool_cfgable.h"
|
|
|
|
#include "tool_doswin.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "memdebug.h" /* LAST include file */
|
|
|
|
|
|
|
|
static CURLcode unit_setup(void)
|
|
|
|
{
|
2016-02-06 02:37:39 +08:00
|
|
|
return CURLE_OK;
|
2016-02-05 14:44:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void unit_stop(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(MSDOS) || defined(WIN32)
|
|
|
|
|
2016-11-23 15:49:04 +08:00
|
|
|
static char *getflagstr(int flags)
|
|
|
|
{
|
2016-02-05 14:44:27 +08:00
|
|
|
char *buf = malloc(256);
|
2017-04-30 19:35:17 +08:00
|
|
|
if(buf) {
|
2018-11-22 16:01:24 +08:00
|
|
|
msnprintf(buf, 256, "%s,%s,%s,%s",
|
|
|
|
((flags & SANITIZE_ALLOW_COLONS) ?
|
|
|
|
"SANITIZE_ALLOW_COLONS" : ""),
|
|
|
|
((flags & SANITIZE_ALLOW_PATH) ?
|
|
|
|
"SANITIZE_ALLOW_PATH" : ""),
|
|
|
|
((flags & SANITIZE_ALLOW_RESERVED) ?
|
|
|
|
"SANITIZE_ALLOW_RESERVED" : ""),
|
|
|
|
((flags & SANITIZE_ALLOW_TRUNCATE) ?
|
|
|
|
"SANITIZE_ALLOW_TRUNCATE" : ""));
|
2017-04-30 19:35:17 +08:00
|
|
|
}
|
2016-02-05 14:44:27 +08:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2016-11-23 15:49:04 +08:00
|
|
|
static char *getcurlcodestr(int cc)
|
|
|
|
{
|
2016-02-05 14:44:27 +08:00
|
|
|
char *buf = malloc(256);
|
2017-04-30 19:35:17 +08:00
|
|
|
if(buf) {
|
2018-11-22 16:01:24 +08:00
|
|
|
msnprintf(buf, 256, "%s (%d)",
|
|
|
|
(cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" :
|
|
|
|
cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" :
|
|
|
|
cc == SANITIZE_ERR_INVALID_PATH ? "SANITIZE_ERR_INVALID_PATH" :
|
|
|
|
cc == SANITIZE_ERR_OUT_OF_MEMORY ? "SANITIZE_ERR_OUT_OF_MEMORY":
|
|
|
|
"unexpected error code - add name"),
|
|
|
|
cc);
|
2017-04-30 19:35:17 +08:00
|
|
|
}
|
2016-02-05 14:44:27 +08:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct data {
|
|
|
|
const char *input;
|
|
|
|
int flags;
|
|
|
|
const char *expected_output;
|
2020-05-29 03:51:25 +08:00
|
|
|
SANITIZEcode expected_result;
|
2016-02-05 14:44:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
UNITTEST_START
|
|
|
|
{ /* START sanitize_file_name */
|
|
|
|
struct data data[] = {
|
|
|
|
{ "", 0,
|
|
|
|
"", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "normal filename", 0,
|
|
|
|
"normal filename", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "control\tchar", 0,
|
|
|
|
"control_char", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "banned*char", 0,
|
|
|
|
"banned_char", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:foo", 0,
|
|
|
|
"f_foo", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:foo", SANITIZE_ALLOW_COLONS,
|
|
|
|
"f:foo", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:foo", SANITIZE_ALLOW_PATH,
|
|
|
|
"f:foo", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:\\foo", 0,
|
|
|
|
"f__foo", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:\\foo", SANITIZE_ALLOW_PATH,
|
|
|
|
"f:\\foo", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:/foo", 0,
|
|
|
|
"f__foo", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:/foo", SANITIZE_ALLOW_PATH,
|
|
|
|
"f:/foo", SANITIZE_ERR_OK
|
|
|
|
},
|
2016-02-09 16:28:58 +08:00
|
|
|
#ifndef MSDOS
|
|
|
|
{ "\\\\?\\C:\\foo", SANITIZE_ALLOW_PATH,
|
|
|
|
"\\\\?\\C:\\foo", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "\\\\?\\C:\\foo", 0,
|
|
|
|
"____C__foo", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
#endif
|
2016-02-05 14:44:27 +08:00
|
|
|
{ "foo:bar", 0,
|
|
|
|
"foo_bar", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "foo|<>/bar\\\":?*baz", 0,
|
|
|
|
"foo____bar_____baz", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:foo::$DATA", 0,
|
|
|
|
"f_foo__$DATA", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "con . air", 0,
|
|
|
|
"con _ air", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "con.air", 0,
|
|
|
|
"con_air", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "con:/x", 0,
|
|
|
|
"con__x", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "file . . . . .. .", 0,
|
|
|
|
"file", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "foo . . ? . . ", 0,
|
|
|
|
"foo . . _", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "com1", 0,
|
|
|
|
"_com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "com1", SANITIZE_ALLOW_RESERVED,
|
|
|
|
"com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:\\com1", 0,
|
|
|
|
"f__com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:\\com1", SANITIZE_ALLOW_PATH,
|
|
|
|
"f:\\_com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:\\com1", SANITIZE_ALLOW_RESERVED,
|
|
|
|
"f__com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:\\com1", SANITIZE_ALLOW_RESERVED | SANITIZE_ALLOW_COLONS,
|
|
|
|
"f:_com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "f:\\com1", SANITIZE_ALLOW_RESERVED | SANITIZE_ALLOW_PATH,
|
|
|
|
"f:\\com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "com1:\\com1", SANITIZE_ALLOW_PATH,
|
|
|
|
"_com1:\\_com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "com1:\\com1", SANITIZE_ALLOW_RESERVED | SANITIZE_ALLOW_PATH,
|
|
|
|
"com1:\\com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "com1:\\com1", SANITIZE_ALLOW_RESERVED,
|
|
|
|
"com1__com1", SANITIZE_ERR_OK
|
|
|
|
},
|
2016-02-09 16:28:58 +08:00
|
|
|
#ifndef MSDOS
|
|
|
|
{ "\\com1", SANITIZE_ALLOW_PATH,
|
|
|
|
"\\_com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "\\\\com1", SANITIZE_ALLOW_PATH,
|
|
|
|
"\\\\com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "\\\\?\\C:\\com1", SANITIZE_ALLOW_PATH,
|
|
|
|
"\\\\?\\C:\\com1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
#endif
|
2016-02-05 14:44:27 +08:00
|
|
|
{ "CoM1", 0,
|
|
|
|
"_CoM1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "CoM1", SANITIZE_ALLOW_RESERVED,
|
|
|
|
"CoM1", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
{ "COM56", 0,
|
|
|
|
"COM56", SANITIZE_ERR_OK
|
|
|
|
},
|
|
|
|
/* At the moment we expect a maximum path length of 259. I assume MSDOS
|
|
|
|
has variable max path lengths depending on compiler that are shorter
|
|
|
|
so currently these "good" truncate tests won't run on MSDOS */
|
|
|
|
#ifndef MSDOS
|
|
|
|
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
|
|
|
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
|
|
|
"CCCCCCCCCCCCCCCCCCCCCC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DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
|
|
|
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
|
|
|
"FF\\F:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
|
|
|
SANITIZE_ALLOW_TRUNCATE | SANITIZE_ALLOW_PATH,
|
|
|
|
NULL, SANITIZE_ERR_INVALID_PATH
|
|
|
|
},
|
|
|
|
{ NULL, 0,
|
|
|
|
NULL, SANITIZE_ERR_BAD_ARGUMENT
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t i;
|
|
|
|
|
2018-05-12 05:40:58 +08:00
|
|
|
for(i = 0; i < sizeof(data) / sizeof(data[0]); ++i) {
|
2016-02-05 14:44:27 +08:00
|
|
|
char *output = NULL;
|
|
|
|
char *flagstr = NULL;
|
|
|
|
char *received_ccstr = NULL;
|
|
|
|
char *expected_ccstr = NULL;
|
2020-05-29 03:51:25 +08:00
|
|
|
SANITIZEcode res;
|
2016-02-05 14:44:27 +08:00
|
|
|
|
2020-05-29 03:51:25 +08:00
|
|
|
res = sanitize_file_name(&output, data[i].input, data[i].flags);
|
2016-02-05 14:44:27 +08:00
|
|
|
|
|
|
|
if(res == data[i].expected_result &&
|
|
|
|
((!output && !data[i].expected_output) ||
|
|
|
|
(output && data[i].expected_output &&
|
|
|
|
!strcmp(output, data[i].expected_output)))) { /* OK */
|
|
|
|
free(output);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
flagstr = getflagstr(data[i].flags);
|
2017-04-30 19:35:17 +08:00
|
|
|
abort_unless(flagstr, "out of memory");
|
2016-02-05 14:44:27 +08:00
|
|
|
received_ccstr = getcurlcodestr(res);
|
2017-04-30 19:35:17 +08:00
|
|
|
abort_unless(received_ccstr, "out of memory");
|
2016-02-05 14:44:27 +08:00
|
|
|
expected_ccstr = getcurlcodestr(data[i].expected_result);
|
2017-04-30 19:35:17 +08:00
|
|
|
abort_unless(expected_ccstr, "out of memory");
|
2016-02-05 14:44:27 +08:00
|
|
|
|
|
|
|
unitfail++;
|
|
|
|
fprintf(stderr, "\n"
|
|
|
|
"%s:%d sanitize_file_name failed.\n"
|
|
|
|
"input: %s\n"
|
|
|
|
"flags: %s\n"
|
|
|
|
"output: %s\n"
|
|
|
|
"result: %s\n"
|
|
|
|
"expected output: %s\n"
|
|
|
|
"expected result: %s\n",
|
|
|
|
__FILE__, __LINE__,
|
|
|
|
data[i].input,
|
|
|
|
flagstr,
|
|
|
|
(output ? output : "(null)"),
|
|
|
|
received_ccstr,
|
|
|
|
(data[i].expected_output ? data[i].expected_output : "(null)"),
|
|
|
|
expected_ccstr);
|
|
|
|
|
|
|
|
free(output);
|
|
|
|
free(flagstr);
|
|
|
|
free(received_ccstr);
|
|
|
|
free(expected_ccstr);
|
|
|
|
}
|
|
|
|
} /* END sanitize_file_name */
|
|
|
|
|
|
|
|
#else
|
|
|
|
UNITTEST_START
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Skipped test not for this platform\n");
|
|
|
|
}
|
|
|
|
#endif /* MSDOS || WIN32 */
|
|
|
|
|
|
|
|
UNITTEST_STOP
|