Hi Martin, having an abort() without a message is simply a big waste of time for any developer who stumbles upon it.
Since the init code of Wget has to be rewritten anyways, i provide the fastest solution right now: increasing the buffer size and printing a message before Wget aborts. And yes, the whole issue is hell stupid... Regards, Tim Am Freitag, 10. Mai 2013 schrieb Marlin Frickenschmidt: > Hello dear wget maintainers, > I want to report a bug of sorts. It is not a direct bug that impedes the > operation of wget to normal users, but one which basically makes it > impossible to add more command-line options to wget without sooner or > later making wget suddenly SIGABRT - without any inclination to show a > proper error whatsover. > > The reason for this is the "no_prefix" function, which is supposed to > prepend the string "no-" to a given string (for disabling certain > command line options). The function makes the assumption that the total > length of all command line option names together won't exceed 1024 > characters, because the buffer storing the strings for all the > "no-"-prefixed command line options is only chosen that large. And so if > it gets too big, there is just a silent abort(), no error message, no > nothing. > > Why don't we use standard functions like asprintf to prepend strings, > and instead build an own, completely broken function for it? Perhaps > there are good reasons for building the string yourself instead of using > the standard library; I don't know. In any case, there is no excuse for > silently abort()ing without an error message. That is the only thing I > am grumpy about, really... > > I hope this can be fixed in the next release for the sake of all wget > developers around. I just spent two hours debugging this, and really > couldn't believe my eyes when I found the reason for it. It is hell stupid. > > Cheers, > Marlin > >
From e21315b9b4d41987479427ed203ae402695ec4df Mon Sep 17 00:00:00 2001 From: Tim Ruehsen <[email protected]> Date: Sat, 11 May 2013 17:11:51 +0200 Subject: [PATCH 3/3] warn before abort() in main.c/no_prefix --- src/ChangeLog | 4 ++++ src/main.c | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 3b6733e..bcff0f7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2013-05-11 Tim Ruehsen <[email protected]> + + * main.c (init_switches): warn before abort() in no_prefix() + 2013-05-09 Tim Ruehsen <[email protected]> * cookies.c, ftp-ls.c, ftp.c, init.c, netrc.c, utils.c, utils.h: diff --git a/src/main.c b/src/main.c index 2b42d2d..70ce651 100644 --- a/src/main.c +++ b/src/main.c @@ -320,13 +320,15 @@ static struct cmdline_option option_data[] = static char * no_prefix (const char *s) { - static char buffer[1024]; + static char buffer[2048]; static char *p = buffer; char *cp = p; int size = 3 + strlen (s) + 1; /* "no-STRING\0" */ - if (p + size >= buffer + sizeof (buffer)) + if (p + size >= buffer + sizeof (buffer)) { + fprintf (stderr, _("Internal error: size of 'buffer' in main.c/no-prefix() must be increased\n")); abort (); + } cp[0] = 'n', cp[1] = 'o', cp[2] = '-'; strcpy (cp + 3, s); @@ -352,6 +354,7 @@ init_switches (void) { char *p = short_options; size_t i, o = 0; + for (i = 0; i < countof (option_data); i++) { struct cmdline_option *opt = &option_data[i]; -- 1.7.10.4
