misc/120256: ftp -u URL/<file> <file> returns a -1 exit code on success

Spencer Minear minear at securecomputing.com
Mon Feb 4 07:20:04 PST 2008


>Number:         120256
>Category:       misc
>Synopsis:       ftp -u URL/<file> <file> returns a -1 exit code on success
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Feb 04 15:20:03 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Spencer Minear
>Release:        Found on 6.2 but still present in current
>Organization:
Secure Computing Corp
>Environment:
6.2-RELEASE
>Description:
Note the results of the thee supported uses of the 'ftp -u' command.

    Transfer one file to a named place

      ftp -u ftp://minear:pby-5-cat@freebe1.slap.org/TE.db TE.db
      echo $?
      255

    Transfer one file to a directory
      ftp -u ftp://minear:pby-5-cat@freebe1.slap.org/ TE.db
      echo $?
      0

    Transfer two files to a direcgtory

      ftp -u ftp://minear:pby-5-cat@freebe1.slap.org/ TE.db foo
      echo $?
      0

All three of these transfers completed successfully but the first is giving a bad exit code.

I believe the error is at the end of the auto_put function in src/contrib/lukemftp/src/fetch.c.

	if (uargc == 3) {
		uargv[1] = argv[0];
		put(uargc, uargv);
		goto cleanup_auto_put;
	}

	for(; argv[0] != NULL; argv++) {
		uargv[1] = argv[0];
		mput(uargc, uargv);
	}
	rval = 0;

 cleanup_auto_put:
	FREEPTR(uargv[2]);
	return (rval);

The first example above uses passes throught the uargc == 3 code and thus does not set the rval to 0.  The other two cases use the for loop and then do set the rval to 0.  The solution can be done by adding a rval = 0 following the call to put or to place the for loop in an else block and remove teh goto cleanup.  I think I prefer the later solution.


>How-To-Repeat:
See examples in the full description.
>Fix:
See the recommended code change in the full description.

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list