Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Mar 1997 20:10:56 +1030 (CST)
From:      Peter Childs <pjchilds@imforei.apana.org.au>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/2947: fetch doesn't handle FTP_TIMEOUT correctly?
Message-ID:  <199703110940.UAA08203@al.imforei.apana.org.au>
Resent-Message-ID: <199703110950.BAA09946@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         2947
>Category:       bin
>Synopsis:       fetch doesn't handle FTP_TIMEOUT correctly?
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 11 01:50:02 PST 1997
>Last-Modified:
>Originator:     Peter Childs
>Organization:
>Release:        FreeBSD 2.2-GAMMA i386 (and 3.0-current)
>Environment:

 	2.2-gamma 

>Description:

 /usr/src/usr.bin/fetch/ftp.c has this bit of code...

                        errno = 0;
                        ul = strtoul(env, &ep, 0);
                        if (*env && *ep && errno == 0 && ul <= INT_MAX)
                                fs->fs_timeout = ul;

 and the man page for strtoul says...

     unsigned long
     strtoul(const char *nptr, char **endptr, int base)
 ...
     If endptr is non nil, strtoul() stores the address of the first invalid
     character in *endptr. If there were no digits at all, however, strtoul()
     stores the original value of nptr in *endptr. (Thus, if *nptr is not `\0'
     but **endptr is `\0' on return, the entire string was valid.)

 but we have the endptr bit the wrong way around (i think.. hey.. I only
 work here :)

>How-To-Repeat:

 Set FTP_TIMEOUT to a valid time (ie something less than INT_MAX) and watch
 this statement bail 'cause *ep is never true.

>Fix:

 Add a bang.. or for the humour impaired apply this patch.
	
*** ftp.c.orig  Tue Mar 11 19:56:09 1997
--- ftp.c       Tue Mar 11 19:56:25 1997
***************
*** 367,373 ****
                if (env) {
                        errno = 0;
                        ul = strtoul(env, &ep, 0);
!                       if (*env && *ep && errno == 0 && ul <= INT_MAX)
                                fs->fs_timeout = ul;
                        else
                                warnx("`%s': invalid FTP timeout", env);
--- 367,373 ----
                if (env) {
                        errno = 0;
                        ul = strtoul(env, &ep, 0);
!                       if (*env && ! *ep && errno == 0 && ul <= INT_MAX)
                                fs->fs_timeout = ul;
                        else
                                warnx("`%s': invalid FTP timeout", env);
                                                                     

>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703110940.UAA08203>