[BusyBox] bug in -pre8: wget http://1.2.3.4/dir/ sends "GET /dir", not "GET /dir/"

Denis Vlasenko vda at port.imtp.ilyichevsk.odessa.ua
Thu May 13 21:34:46 UTC 2004


Here's why:

wget.c: this is the place where target.path loses trailing '/':
=======
        if (!fname_out) {
                fname_out =
#ifdef CONFIG_FEATURE_WGET_STATUSBAR
                        curfile =
#endif
                        bb_get_last_path_component(target.path);


get_last_path_component.c: 'last[1] = 0' is guilty
==========================
char *bb_get_last_path_component(char *path)
{
#if EMULATE_BASENAME
        static const char null_or_empty[] = ".";
#endif
        char *first = path;
        char *last;

#if EMULATE_BASENAME
        if (!path || !*path) {
                return (char *) null_or_empty;
        }
#endif

        last = path - 1;

        while (*path) {
                if ((*path != '/') && (path > ++last)) {
                        last = first = path;
                }
                ++path;
        }

        if (*first == '/') {
                last = first;
        }
        last[1] = 0;

        return first;
}

bb_get_last_path_component() should be either documented (and renamed?)
to mangle its parameter of fixed to not do that. A dozen of applets is
using it, I hesitate to break 'em by fix...
--
vda




More information about the busybox mailing list