Subject: bin/8534: Undefined C in ftpd/ftpcmd.y
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dholland@eecs.harvard.edu>
List: netbsd-bugs
Date: 10/02/1999 11:05:47
>Number:         8534
>Category:       bin
>Synopsis:       Undefined C in ftpd/ftpcmd.y
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct  2 11:05:01 1999
>Last-Modified:
>Originator:     David A. Holland <dholland@eecs.harvard.edu>
>Organization:
   - David A. Holland             |    VINO project home page:
     dholland@eecs.harvard.edu    | http://www.eecs.harvard.edu/vino
>Release:        NetBSD-current of 19991002
>Environment:

	This was found elsewhere, but applies to today's -current sources.

>Description:

	ftpcmd.y contains an expression of the form "a = ++a;" which is
	undefined in C.

	The precise offending statement is
		state = state == OSTR ? STR2 : ++state;
	I believe the correct expression is to use "state+1" instead 
	of "++state".

	This was actually caught by Phil Copeland <root@zen.ics.uwe.ac.uk>.

>How-To-Repeat:

	Apparently, compiling ftpd with the DEC alpha compiler causes it
	to warn about the expression in question.

>Fix:

	Patch (not actually tested yet):

--- ftpcmd.y.orig	Sat Oct  2 13:29:42 1999
+++ ftpcmd.y	Sat Oct  2 13:30:53 1999
@@ -1514,11 +1514,11 @@
 	case STR1:
 	case ZSTR1:
 	dostr1:
 		if (cbuf[cpos] == ' ') {
 			cpos++;
-			state = state == OSTR ? STR2 : ++state;
+			state = state == OSTR ? STR2 : state+1;
 			return (SP);
 		}
 		break;
 
 	case ZSTR2:

>Audit-Trail:
>Unformatted: