Subject: bin/15451: usr.bin/ftp macro behavior non-intuitive
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itojun@itojun.org>
List: netbsd-bugs
Date: 02/01/2002 14:44:58
>Number:         15451
>Category:       bin
>Synopsis:       usr.bin/ftp macro behavior non-intuitive
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 31 21:46:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jun-ichiro itojun Hagino
>Release:        NetBSD 1.5ZA
>Organization:
	itojun.org
>Environment:
System: NetBSD starfruit.itojun.org 1.5ZA NetBSD 1.5ZA (STARFRUIT) #: Fri Feb 1 11:49:09 JST 2002 itojun@starfruit.itojun.org:/usr/home/itojun/NetBSD/src/sys/arch/i386/compile/STARFRUIT i386
Architecture: i386
Machine: i386
>Description:
	with the current usr.bin/ftp, the behavior of "macdef" command is
	rather non-intuitive.
	- if you "macdef" the same macro name twice, they will be entered to
	  the macro database as a different macro.  the first one defined is
	  actually invoked on $foo (2nd and other definitions are in memory,
	  but will not be used).
	- if you define macro that expands to longer string, $n reference
	  will not work correctly.
>How-To-Repeat:
	- repeat "macdef foo" for 16 times.  see "Limit of 16 macros have
	  already been defined." error.
	- do the following.

ftp> macdef hoge
Enter macro line by line, terminating it with a null line.
$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0
$1$1$1$1$1
$2$2$2$2$2

ftp> $hoge get
it will be expanded to the following three commands:
hogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehoge
ogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogeogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogeogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogeogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogeogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehoge
(empty string)

ftp> macdef hoge
Enter macro line by line, terminating it with a null line.
$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0
$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0
$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0

ftp> $hoge get
segmentation fault

>Fix:
	revisit usr.bin/ftp/domacro.c
>Release-Note:
>Audit-Trail:
>Unformatted: