Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!vaxine!wjh12!genrad!decvax!ittvax!bunker!allen From: allen@bunker.UUCP (C. Allen Grabert) Newsgroups: net.unix-wizards Subject: Bug in doscan.c Message-ID: <378@bunker.UUCP> Date: Thu, 19-Apr-84 10:03:48 EST Article-I.D.: bunker.378 Posted: Thu Apr 19 10:03:48 1984 Date-Received: Fri, 20-Apr-84 01:25:36 EST Lines: 18 Not being a regular reader of this newsgroup or an "experienced" systems programmer, I have no idea if this bug has been noted before, but here goes. 'doscan.c', the common code for the 'scanf' routines, has a bug whereby a program can go into an infinite loop. One of our employees was reading hex numbers and encountered an invalid hex digit; the program promptly looped. At roughly line 174 of the code there are the lines: if (c != EOF) { ungetc(c, iop); ... The code assumes that a number has been decoded and the value of 'c' is the character following the number. However, the code should first check to see if a number has actually been decoded or if the character is the first character of the number. One possibility is to insert the line: if (np == numbuf) excuse me, make that: if (np > numbuf) between the two lines mentioned above. However, I am not in a position to make a change and see if it works properly for a group of users, so please take my suggestion as an educated guess.