rad@puffin.USS.TEK.COM (Richard Doty) (11/26/87)
Index: ksh/sh/name.c Description: When using a non-default input field separator (such as ':'), trailing empty data fields cause ksh to underflow an input stack, and thus fail to correctly null-terminate the string before assigning it to the variable being read. This bug is present in both ksh (Version 02/21/85) and ksh-i (Version 06/03/86a) as distributed by the AT&T toolchest. Repeat-By: Execute this shell file: IFS=:$IFS while read f1 f2 f3 do echo f1=\""$f1"\" f2=\""$f2"\" f3=\""$f3"\" done <<E-O-F rec1.f1:rec1.f2:rec1.f3 rec2.f1:rec2.f2:: rec3.f1:rec3.f2:: E-O-F # correct behavior: # # $ sh g # f1="rec1.f1" f2="rec1.f2" f3="rec1.f3" # f1="rec2.f1" f2="rec2.f2" f3=":" # f1="rec3.f1" f2="rec3.f2" f3=":" # $ # # incorrect behavior (note field 3): # # $ ENV= ksh g # f1="rec1.f1" f2="rec1.f2" f3="rec1.f3" # f1="rec2.f1" f2="rec2.f2" f3=":ec2.f2" # f1="rec3.f1" f2="rec3.f2" f3=":ec3.f2" # $ Fix: In readvar() in name.c, where the top of the stack is being decremented past any trailing separators, make sure it doesn't go past the bottom of the stack.