Thread View: comp.bugs.misc
1 messages
1 total messages
Started by Richard Doty
Thu, 26 Nov 1987 01:18
ksh returns erroneous data when there are trailing empty fields
Author: Richard Doty
Date: Thu, 26 Nov 1987 01:18
Date: Thu, 26 Nov 1987 01:18
44 lines
1714 bytes
1714 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads