Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!brl-smoke!smoke!sscalsk@nswc-wo.arpa From: sscalsk@nswc-wo.arpa Newsgroups: net.unix-wizards Subject: getpwnam bug Message-ID: <3345@brl-smoke.ARPA> Date: Wed, 27-Aug-86 12:40:57 EDT Article-I.D.: brl-smok.3345 Posted: Wed Aug 27 12:40:57 1986 Date-Received: Wed, 27-Aug-86 21:51:26 EDT Sender: news@brl-smoke.ARPA Lines: 34 Jim, You are correct. Adding a blank line to the head of the passwd file on a vanilla 4.2BSD system does not have a problem because of the following: On a vanilla 4.2BSD (which I also have) the routine fgetpwent does not exist. Is this true for you? (NOTE: fgetpwent takes 1 parm - a file pointer to the passwd file). The routine getpwent does all the necessary processing. Processing of the line read by the fgets is done even if the fgets returned a line containing only a '\n'. The source shows no further checking on the contents of the line read by the fgets. In taking a closer look at the code on my system it proceeds as follows: getpwent: calls fgetpwent: which does the following p=fgets(line, BUFSIZ, f); if (p == NULL) return(NULL); assign pw_name from p p = pwskip(p) assign pw_passwd from p p = pwskip(p) if (p == NULL || *p == ':') return (NULL) I was incorrect in saying it was the fgets returning the NULL when in fact it is the final return of the example (after the pwskip processing) that is returning the NULL. You might also be correct in that it is the SYS III part of the system that this code is from. It sure doesnt look like vendor modified code, but not having access to anything but 4.2BSD it is hard to verify. Stan Scalsky Naval Surface Weapons Center - White Oak ARPA: sscalsk@nswc-wo.arpa Compuserve: 70337,2015