summaryrefslogtreecommitdiff
path: root/src/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/init.c')
-rw-r--r--src/init.c300
1 files changed, 162 insertions, 138 deletions
diff --git a/src/init.c b/src/init.c
index a64dabe..088a6e9 100644
--- a/src/init.c
+++ b/src/init.c
@@ -1,6 +1,6 @@
/* Reading/parsing the initialization file.
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation,
+ 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2014 Free Software Foundation,
Inc.
This file is part of GNU Wget.
@@ -68,6 +68,9 @@ as that of the covered work. */
#include "http.h" /* for http_cleanup */
#include "retr.h" /* for output_stream */
#include "warc.h" /* for warc_close */
+#include "spider.h" /* for spider_cleanup */
+#include "html-url.h" /* for cleanup_html_url */
+#include "c-strcase.h"
#ifdef TESTING
#include "test.h"
@@ -89,6 +92,7 @@ CMD_DECLARE (cmd_number_inf);
CMD_DECLARE (cmd_string);
CMD_DECLARE (cmd_string_uppercase);
CMD_DECLARE (cmd_file);
+CMD_DECLARE (cmd_file_once);
CMD_DECLARE (cmd_directory);
CMD_DECLARE (cmd_time);
CMD_DECLARE (cmd_vector);
@@ -149,18 +153,19 @@ static const struct {
{ "certificatetype", &opt.cert_type, cmd_cert_type },
{ "checkcertificate", &opt.check_cert, cmd_boolean },
#endif
- { "chooseconfig", &opt.choose_config, cmd_file },
+ { "chooseconfig", &opt.choose_config, cmd_file },
{ "connecttimeout", &opt.connect_timeout, cmd_time },
{ "contentdisposition", &opt.content_disposition, cmd_boolean },
{ "contentonerror", &opt.content_on_error, cmd_boolean },
{ "continue", &opt.always_rest, cmd_boolean },
{ "convertlinks", &opt.convert_links, cmd_boolean },
{ "cookies", &opt.cookies, cmd_boolean },
+#ifdef HAVE_SSL
+ { "crlfile", &opt.crl_file, cmd_file_once },
+#endif
{ "cutdirs", &opt.cut_dirs, cmd_number },
-#ifdef ENABLE_DEBUG
{ "debug", &opt.debug, cmd_boolean },
-#endif
- { "defaultpage", &opt.default_page, cmd_string },
+ { "defaultpage", &opt.default_page, cmd_string },
{ "deleteafter", &opt.delete_after, cmd_boolean },
{ "dirprefix", &opt.dir_prefix, cmd_directory },
{ "dirstruct", NULL, cmd_spec_dirstruct },
@@ -220,6 +225,7 @@ static const struct {
{ "mirror", NULL, cmd_spec_mirror },
{ "netrc", &opt.netrc, cmd_boolean },
{ "noclobber", &opt.noclobber, cmd_boolean },
+ { "noconfig", &opt.noconfig, cmd_boolean },
{ "noparent", &opt.no_parent, cmd_boolean },
{ "noproxy", &opt.no_proxy, cmd_vector },
{ "numtries", &opt.ntry, cmd_number_inf },/* deprecated*/
@@ -269,8 +275,10 @@ static const struct {
#endif
{ "serverresponse", &opt.server_response, cmd_boolean },
{ "showalldnsentries", &opt.show_all_dns_entries, cmd_boolean },
+ { "showprogress", &opt.show_progress, cmd_boolean },
{ "spanhosts", &opt.spanhost, cmd_boolean },
{ "spider", &opt.spider, cmd_boolean },
+ { "startpos", &opt.start_pos, cmd_bytes },
{ "strictcomments", &opt.strict_comments, cmd_boolean },
{ "timeout", NULL, cmd_spec_timeout },
{ "timestamping", &opt.timestamping, cmd_boolean },
@@ -313,7 +321,7 @@ command_by_name (const char *cmdname)
while (lo <= hi)
{
int mid = (lo + hi) >> 1;
- int cmp = strcasecmp (cmdname, commands[mid].name);
+ int cmp = c_strcasecmp (cmdname, commands[mid].name);
if (cmp < 0)
hi = mid - 1;
else if (cmp > 0)
@@ -323,7 +331,7 @@ command_by_name (const char *cmdname)
}
return -1;
}
-
+
/* Reset the variables to default values. */
void
defaults (void)
@@ -364,6 +372,22 @@ defaults (void)
opt.dns_cache = true;
opt.ftp_pasv = true;
+ /* 2014-09-07 Darshit Shah <darnir@gmail.com>
+ * opt.retr_symlinks is set to true by default. Creating symbolic links on the
+ * local filesystem pose a security threat by malicious FTP Servers that
+ * server a specially crafted .listing file akin to this:
+ *
+ * lrwxrwxrwx 1 root root 33 Dec 25 2012 JoCxl6d8rFU -> /
+ * drwxrwxr-x 15 1024 106 4096 Aug 28 02:02 JoCxl6d8rFU
+ *
+ * A .listing file in this fashion makes Wget susceptiple to a symlink attack
+ * wherein the attacker is able to create arbitrary files, directories and
+ * symbolic links on the target system and even set permissions.
+ *
+ * Hence, by default Wget attempts to retrieve the pointed-to files and does
+ * not create the symbolic links locally.
+ */
+ opt.retr_symlinks = true;
#ifdef HAVE_SSL
opt.check_cert = true;
@@ -407,8 +431,13 @@ defaults (void)
opt.warc_cdx_dedup_filename = NULL;
opt.warc_tempdir = NULL;
opt.warc_keep_log = true;
+
+ /* Use a negative value to mark the absence of --start-pos option */
+ opt.start_pos = -1;
+ opt.show_progress = false;
+ opt.noscroll = false;
}
-
+
/* Return the user's home directory (strdup-ed), or NULL if none is
found. */
char *
@@ -438,12 +467,7 @@ home_dir (void)
assert (p);
len = p - buff + 1;
- buff = malloc (len + 1);
- if (buff == NULL)
- return NULL;
-
- strncpy (buff, _w32_get_argv0 (), len);
- buff[len] = '\0';
+ buff = strdup (_w32_get_argv0 ());
home = buf;
#elif !defined(WINDOWS)
@@ -462,7 +486,7 @@ home_dir (void)
}
ret = home ? xstrdup (home) : NULL;
- free (buf);
+ xfree (buf);
return ret;
}
@@ -481,7 +505,7 @@ wgetrc_env_file_name (void)
{
fprintf (stderr, _("%s: WGETRC points to %s, which doesn't exist.\n"),
exec_name, env);
- exit (1);
+ exit (WGET_EXIT_GENERIC_ERROR);
}
return xstrdup (env);
}
@@ -503,7 +527,7 @@ wgetrc_user_file_name (void)
home = home_dir ();
if (home)
file = aprintf ("%s/.wgetrc", home);
- xfree_null (home);
+ xfree (home);
#endif /* def __VMS [else] */
if (!file)
@@ -538,8 +562,7 @@ wgetrc_file_name (void)
if (!file)
{
char *home = home_dir ();
- xfree_null (file);
- file = NULL;
+ xfree (file);
home = ws_mypath ();
if (home)
{
@@ -547,7 +570,6 @@ wgetrc_file_name (void)
if (!file_exists_p (file))
{
xfree (file);
- file = NULL;
}
xfree (home);
}
@@ -621,8 +643,8 @@ run_wgetrc (const char *file)
default:
abort ();
}
- xfree_null (com);
- xfree_null (val);
+ xfree (com);
+ xfree (val);
++ln;
}
xfree (line);
@@ -653,7 +675,7 @@ initialize (void)
Parsing system wgetrc file (env SYSTEM_WGETRC) failed. Please check\n\
'%s',\n\
or specify a different file using --config.\n"), env_sysrc);
- exit (2);
+ exit (WGET_EXIT_PARSE_ERROR);
}
}
/* Otherwise, if SYSTEM_WGETRC is defined, use it. */
@@ -668,7 +690,7 @@ or specify a different file using --config.\n"), env_sysrc);
Parsing system wgetrc file failed. Please check\n\
'%s',\n\
or specify a different file using --config.\n"), SYSTEM_WGETRC);
- exit (2);
+ exit (WGET_EXIT_PARSE_ERROR);
}
#endif
/* Override it with your own, if one exists. */
@@ -690,7 +712,7 @@ or specify a different file using --config.\n"), SYSTEM_WGETRC);
/* If there were errors processing either `.wgetrc', abort. */
if (!ok)
- exit (2);
+ exit (WGET_EXIT_PARSE_ERROR);
xfree (file);
return;
@@ -814,16 +836,16 @@ setval_internal_tilde (int comind, const char *com, const char *val)
pstring = commands[comind].place;
home = home_dir ();
if (home)
- {
- homelen = strlen (home);
- while (homelen && ISSEP (home[homelen - 1]))
- home[--homelen] = '\0';
-
- /* Skip the leading "~/". */
- for (++val; ISSEP (*val); val++)
- ;
- *pstring = concat_strings (home, "/", val, (char *)0);
- }
+ {
+ homelen = strlen (home);
+ while (homelen && ISSEP (home[homelen - 1]))
+ home[--homelen] = '\0';
+
+ /* Skip the leading "~/". */
+ for (++val; ISSEP (*val); val++)
+ ;
+ *pstring = concat_strings (home, "/", val, (char *)0);
+ }
}
return ret;
}
@@ -831,8 +853,8 @@ setval_internal_tilde (int comind, const char *com, const char *val)
/* Run command COM with value VAL. If running the command produces an
error, report the error and exit.
- This is intended to be called from main() to modify Wget's behavior
- through command-line switches. Since COM is hard-coded in main(),
+ This is intended to be called from main to modify Wget's behavior
+ through command-line switches. Since COM is hard-coded in main,
it is not canonicalized, and this aborts when COM is not found.
If COMIND's are exported to init.h, this function will be changed
@@ -849,7 +871,7 @@ setoptval (const char *com, const char *val, const char *optname)
assert (val != NULL);
if (!setval_internal (command_by_name (com), dd_optname, val))
- exit (2);
+ exit (WGET_EXIT_PARSE_ERROR);
}
/* Parse OPT into command and value and run it. For example,
@@ -857,25 +879,25 @@ setoptval (const char *com, const char *val, const char *optname)
This is used by the `--execute' flag in main.c. */
void
-run_command (const char *opt)
+run_command (const char *cmdopt)
{
char *com, *val;
int comind;
- switch (parse_line (opt, &com, &val, &comind))
+ switch (parse_line (cmdopt, &com, &val, &comind))
{
case line_ok:
if (!setval_internal (comind, com, val))
- exit (2);
+ exit (WGET_EXIT_PARSE_ERROR);
xfree (com);
xfree (val);
break;
default:
fprintf (stderr, _("%s: Invalid --execute command %s\n"),
- exec_name, quote (opt));
- exit (2);
+ exec_name, quote (cmdopt));
+ exit (WGET_EXIT_PARSE_ERROR);
}
}
-
+
/* Generic helper functions, for use with `commands'. */
/* Forward declarations: */
@@ -943,7 +965,7 @@ cmd_number (const char *com, const char *val, void *place)
static bool
cmd_number_inf (const char *com, const char *val, void *place)
{
- if (!strcasecmp (val, "inf"))
+ if (!c_strcasecmp (val, "inf"))
{
*(int *) place = 0;
return true;
@@ -954,22 +976,22 @@ cmd_number_inf (const char *com, const char *val, void *place)
/* Copy (strdup) the string at COM to a new location and place a
pointer to *PLACE. */
static bool
-cmd_string (const char *com, const char *val, void *place)
+cmd_string (const char *com _GL_UNUSED, const char *val, void *place)
{
char **pstring = (char **)place;
- xfree_null (*pstring);
+ xfree (*pstring);
*pstring = xstrdup (val);
return true;
}
/* Like cmd_string but ensure the string is upper case. */
static bool
-cmd_string_uppercase (const char *com, const char *val, void *place)
+cmd_string_uppercase (const char *com _GL_UNUSED, const char *val, void *place)
{
char *q, **pstring;
pstring = (char **)place;
- xfree_null (*pstring);
+ xfree (*pstring);
*pstring = xmalloc (strlen (val) + 1);
@@ -985,11 +1007,11 @@ cmd_string_uppercase (const char *com, const char *val, void *place)
`.wgetrc'. In that case, and if VAL begins with `~', the tilde
gets expanded to the user's home directory. */
static bool
-cmd_file (const char *com, const char *val, void *place)
+cmd_file (const char *com _GL_UNUSED, const char *val, void *place)
{
char **pstring = (char **)place;
- xfree_null (*pstring);
+ xfree (*pstring);
/* #### If VAL is empty, perhaps should set *PLACE to NULL. */
@@ -1007,6 +1029,20 @@ cmd_file (const char *com, const char *val, void *place)
return true;
}
+/* like cmd_file, but insist on just a single option usage */
+static bool
+cmd_file_once (const char *com _GL_UNUSED, const char *val, void *place)
+{
+ if (*(char **)place)
+ {
+ fprintf (stderr, _("%s: %s must only be used once\n"),
+ exec_name, com);
+ return false;
+ }
+
+ return cmd_file(com, val, place);
+}
+
/* Like cmd_file, but strips trailing '/' characters. */
static bool
cmd_directory (const char *com, const char *val, void *place)
@@ -1032,7 +1068,7 @@ cmd_directory (const char *com, const char *val, void *place)
PLACE vector is cleared instead. */
static bool
-cmd_vector (const char *com, const char *val, void *place)
+cmd_vector (const char *com _GL_UNUSED, const char *val, void *place)
{
char ***pvec = (char ***)place;
@@ -1047,7 +1083,7 @@ cmd_vector (const char *com, const char *val, void *place)
}
static bool
-cmd_directory_vector (const char *com, const char *val, void *place)
+cmd_directory_vector (const char *com _GL_UNUSED, const char *val, void *place)
{
char ***pvec = (char ***)place;
@@ -1256,14 +1292,14 @@ cmd_cert_type (const char *com, const char *val, void *place)
return ok;
}
#endif
-
+
/* Specialized helper functions, used by `commands' to handle some
options specially. */
static bool check_user_specified_header (const char *);
static bool
-cmd_spec_dirstruct (const char *com, const char *val, void *place_ignored)
+cmd_spec_dirstruct (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
if (!cmd_boolean (com, val, &opt.dirstruct))
return false;
@@ -1277,7 +1313,7 @@ cmd_spec_dirstruct (const char *com, const char *val, void *place_ignored)
}
static bool
-cmd_spec_header (const char *com, const char *val, void *place_ignored)
+cmd_spec_header (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
/* Empty value means reset the list of headers. */
if (*val == '\0')
@@ -1298,7 +1334,7 @@ cmd_spec_header (const char *com, const char *val, void *place_ignored)
}
static bool
-cmd_spec_warc_header (const char *com, const char *val, void *place_ignored)
+cmd_spec_warc_header (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
/* Empty value means reset the list of headers. */
if (*val == '\0')
@@ -1319,7 +1355,7 @@ cmd_spec_warc_header (const char *com, const char *val, void *place_ignored)
}
static bool
-cmd_spec_htmlify (const char *com, const char *val, void *place_ignored)
+cmd_spec_htmlify (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
int flag = cmd_boolean (com, val, &opt.htmlify);
if (flag && !opt.htmlify)
@@ -1331,7 +1367,7 @@ cmd_spec_htmlify (const char *com, const char *val, void *place_ignored)
no limit on max. recursion depth, and don't remove listings. */
static bool
-cmd_spec_mirror (const char *com, const char *val, void *place_ignored)
+cmd_spec_mirror (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
int mirror;
@@ -1353,7 +1389,7 @@ cmd_spec_mirror (const char *com, const char *val, void *place_ignored)
"IPv4", "IPv6", and "none". */
static bool
-cmd_spec_prefer_family (const char *com, const char *val, void *place_ignored)
+cmd_spec_prefer_family (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
static const struct decode_item choices[] = {
{ "IPv4", prefer_ipv4 },
@@ -1372,7 +1408,7 @@ cmd_spec_prefer_family (const char *com, const char *val, void *place_ignored)
implementation before that. */
static bool
-cmd_spec_progress (const char *com, const char *val, void *place_ignored)
+cmd_spec_progress (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
if (!valid_progress_implementation_p (val))
{
@@ -1380,10 +1416,10 @@ cmd_spec_progress (const char *com, const char *val, void *place_ignored)
exec_name, com, quote (val));
return false;
}
- xfree_null (opt.progress_type);
+ xfree (opt.progress_type);
/* Don't call set_progress_implementation here. It will be called
- in main() when it becomes clear what the log output is. */
+ in main when it becomes clear what the log output is. */
opt.progress_type = xstrdup (val);
return true;
}
@@ -1393,7 +1429,7 @@ cmd_spec_progress (const char *com, const char *val, void *place_ignored)
is specified. */
static bool
-cmd_spec_recursive (const char *com, const char *val, void *place_ignored)
+cmd_spec_recursive (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
if (!cmd_boolean (com, val, &opt.recursive))
return false;
@@ -1408,7 +1444,7 @@ cmd_spec_recursive (const char *com, const char *val, void *place_ignored)
/* Validate --regex-type and set the choice. */
static bool
-cmd_spec_regex_type (const char *com, const char *val, void *place_ignored)
+cmd_spec_regex_type (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
static const struct decode_item choices[] = {
{ "posix", regex_type_posix },
@@ -1425,7 +1461,7 @@ cmd_spec_regex_type (const char *com, const char *val, void *place_ignored)
}
static bool
-cmd_spec_restrict_file_names (const char *com, const char *val, void *place_ignored)
+cmd_spec_restrict_file_names (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
int restrict_os = opt.restrict_files_os;
int restrict_ctrl = opt.restrict_files_ctrl;
@@ -1479,9 +1515,9 @@ cmd_spec_restrict_file_names (const char *com, const char *val, void *place_igno
}
static bool
-cmd_spec_report_speed (const char *com, const char *val, void *place_ignored)
+cmd_spec_report_speed (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
- opt.report_bps = strcasecmp (val, "bits") == 0;
+ opt.report_bps = c_strcasecmp (val, "bits") == 0;
if (!opt.report_bps)
fprintf (stderr, _("%s: %s: Invalid value %s.\n"), exec_name, com, quote (val));
return opt.report_bps;
@@ -1496,6 +1532,8 @@ cmd_spec_secure_protocol (const char *com, const char *val, void *place)
{ "sslv2", secure_protocol_sslv2 },
{ "sslv3", secure_protocol_sslv3 },
{ "tlsv1", secure_protocol_tlsv1 },
+ { "tlsv1_1", secure_protocol_tlsv1_1 },
+ { "tlsv1_2", secure_protocol_tlsv1_2 },
{ "pfs", secure_protocol_pfs },
};
int ok = decode_string (val, choices, countof (choices), place);
@@ -1508,7 +1546,7 @@ cmd_spec_secure_protocol (const char *com, const char *val, void *place)
/* Set all three timeout values. */
static bool
-cmd_spec_timeout (const char *com, const char *val, void *place_ignored)
+cmd_spec_timeout (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
double value;
if (!cmd_time (com, val, &value))
@@ -1520,7 +1558,7 @@ cmd_spec_timeout (const char *com, const char *val, void *place_ignored)
}
static bool
-cmd_spec_useragent (const char *com, const char *val, void *place_ignored)
+cmd_spec_useragent (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
/* Disallow embedded newlines. */
if (strchr (val, '\n'))
@@ -1529,7 +1567,7 @@ cmd_spec_useragent (const char *com, const char *val, void *place_ignored)
exec_name, com, quote (val));
return false;
}
- xfree_null (opt.useragent);
+ xfree (opt.useragent);
opt.useragent = xstrdup (val);
return true;
}
@@ -1539,7 +1577,7 @@ cmd_spec_useragent (const char *com, const char *val, void *place_ignored)
some random hackery for disallowing -q -v). */
static bool
-cmd_spec_verbose (const char *com, const char *val, void *place_ignored)
+cmd_spec_verbose (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
bool flag;
if (cmd_boolean (com, val, &flag))
@@ -1549,7 +1587,7 @@ cmd_spec_verbose (const char *com, const char *val, void *place_ignored)
}
return false;
}
-
+
/* Miscellaneous useful routines. */
/* A very simple atoi clone, more useful than atoi because it works on
@@ -1684,7 +1722,7 @@ decode_string (const char *val, const struct decode_item *items, int itemcount,
{
int i;
for (i = 0; i < itemcount; i++)
- if (0 == strcasecmp (val, items[i].name))
+ if (0 == c_strcasecmp (val, items[i].name))
{
*place = items[i].code;
return true;
@@ -1692,11 +1730,6 @@ decode_string (const char *val, const struct decode_item *items, int itemcount,
return false;
}
-
-void cleanup_html_url (void);
-void spider_cleanup (void);
-
-
/* Free the memory allocated by global variables. */
void
cleanup (void)
@@ -1732,93 +1765,85 @@ cleanup (void)
spider_cleanup ();
host_cleanup ();
log_cleanup ();
+ netrc_cleanup ();
- for (i = 0; i < nurl; i++)
- xfree (url[i]);
-
- {
- extern acc_t *netrc_list;
- free_netrc (netrc_list);
- }
- xfree_null (opt.choose_config);
- xfree_null (opt.lfilename);
- xfree_null (opt.dir_prefix);
- xfree_null (opt.input_filename);
- xfree_null (opt.output_document);
+ xfree (opt.choose_config);
+ xfree (opt.lfilename);
+ xfree (opt.dir_prefix);
+ xfree (opt.input_filename);
+ xfree (opt.output_document);
free_vec (opt.accepts);
free_vec (opt.rejects);
- free_vec (opt.excludes);
- free_vec (opt.includes);
+ free_vec ((char **)opt.excludes);
+ free_vec ((char **)opt.includes);
free_vec (opt.domains);
free_vec (opt.follow_tags);
free_vec (opt.ignore_tags);
- xfree_null (opt.progress_type);
- xfree_null (opt.ftp_user);
- xfree_null (opt.ftp_passwd);
- xfree_null (opt.ftp_proxy);
- xfree_null (opt.https_proxy);
- xfree_null (opt.http_proxy);
+ xfree (opt.progress_type);
+ xfree (opt.ftp_user);
+ xfree (opt.ftp_passwd);
+ xfree (opt.ftp_proxy);
+ xfree (opt.https_proxy);
+ xfree (opt.http_proxy);
free_vec (opt.no_proxy);
- xfree_null (opt.useragent);
- xfree_null (opt.referer);
- xfree_null (opt.http_user);
- xfree_null (opt.http_passwd);
+ xfree (opt.useragent);
+ xfree (opt.referer);
+ xfree (opt.http_user);
+ xfree (opt.http_passwd);
free_vec (opt.user_headers);
free_vec (opt.warc_user_headers);
# ifdef HAVE_SSL
- xfree_null (opt.cert_file);
- xfree_null (opt.private_key);
- xfree_null (opt.ca_directory);
- xfree_null (opt.ca_cert);
- xfree_null (opt.random_file);
- xfree_null (opt.egd_file);
+ xfree (opt.cert_file);
+ xfree (opt.private_key);
+ xfree (opt.ca_directory);
+ xfree (opt.ca_cert);
+ xfree (opt.crl_file);
+ xfree (opt.random_file);
+ xfree (opt.egd_file);
# endif
- xfree_null (opt.bind_address);
- xfree_null (opt.cookies_input);
- xfree_null (opt.cookies_output);
- xfree_null (opt.user);
- xfree_null (opt.passwd);
- xfree_null (opt.base_href);
- xfree_null (opt.method);
+ xfree (opt.bind_address);
+ xfree (opt.cookies_input);
+ xfree (opt.cookies_output);
+ xfree (opt.user);
+ xfree (opt.passwd);
+ xfree (opt.base_href);
+ xfree (opt.method);
+ xfree (opt.post_file_name);
+ xfree (opt.post_data);
+ xfree (opt.body_data);
+ xfree (opt.body_file);
#endif /* DEBUG_MALLOC */
}
-
+
/* Unit testing routines. */
#ifdef TESTING
const char *
-test_commands_sorted()
+test_commands_sorted(void)
{
- int prev_idx = 0, next_idx = 1;
- int command_count = countof (commands) - 1;
- int cmp = 0;
- while (next_idx <= command_count)
+ unsigned i;
+
+ for (i = 1; i < countof(commands); ++i)
{
- cmp = strcasecmp (commands[prev_idx].name, commands[next_idx].name);
- if (cmp > 0)
+ if (c_strcasecmp (commands[i - 1].name, commands[i].name) > 0)
{
mu_assert ("FAILED", false);
break;
}
- else
- {
- prev_idx ++;
- next_idx ++;
- }
}
return NULL;
}
const char *
-test_cmd_spec_restrict_file_names()
+test_cmd_spec_restrict_file_names(void)
{
- int i;
- struct {
- char *val;
+ unsigned i;
+ static const struct {
+ const char *val;
int expected_restrict_files_os;
- int expected_restrict_files_ctrl;
+ bool expected_restrict_files_ctrl;
int expected_restrict_files_case;
bool result;
} test_array[] = {
@@ -1828,7 +1853,7 @@ test_cmd_spec_restrict_file_names()
{ "unix,nocontrol,lowercase,", restrict_unix, false, restrict_lowercase, true },
};
- for (i = 0; i < sizeof(test_array)/sizeof(test_array[0]); ++i)
+ for (i = 0; i < countof(test_array); ++i)
{
bool res;
@@ -1843,13 +1868,12 @@ test_cmd_spec_restrict_file_names()
*/
mu_assert ("test_cmd_spec_restrict_file_names: wrong result",
res == test_array[i].result
- && opt.restrict_files_os == test_array[i].expected_restrict_files_os
+ && (int) opt.restrict_files_os == test_array[i].expected_restrict_files_os
&& opt.restrict_files_ctrl == test_array[i].expected_restrict_files_ctrl
- && opt.restrict_files_case == test_array[i].expected_restrict_files_case);
+ && (int) opt.restrict_files_case == test_array[i].expected_restrict_files_case);
}
return NULL;
}
#endif /* TESTING */
-