Date: Fri, 18 Oct 2002 06:40:05 -0700 (PDT) From: Maxim Konovalov <maxim@macomnet.ru> To: freebsd-bugs@FreeBSD.org Subject: bin/39671 Message-ID: <200210181340.g9IDe53t093122@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/39671; it has been noted by GNATS. From: Maxim Konovalov <maxim@macomnet.ru> To: bug-followup@freebsd.org Cc: Lyndon Nerenberg <lyndon@orthanc.ab.ca> Subject: bin/39671 Date: Fri, 18 Oct 2002 17:36:16 +0400 (MSD) What about more comprehensive patch: o Fix usage() string o Do not dump core on unsetted domainname o Fix passwd file parsing Index: mknetid.c =================================================================== RCS file: /home/ncvs/src/libexec/mknetid/mknetid.c,v retrieving revision 1.12 diff -u -r1.12 mknetid.c --- mknetid.c 17 Feb 2002 19:09:20 -0000 1.12 +++ mknetid.c 18 Oct 2002 13:25:14 -0000 @@ -91,7 +91,7 @@ { fprintf (stderr, "%s\n%s\n", "usage: mknetid [-q] [-g group_file] [-p passwd_file] [-h hosts_file]", - " [-d netid_file] [-d domain]"); + " [-n netid_file] [-d domain]"); exit(1); } @@ -111,6 +111,7 @@ char *ptr, *pidptr, *gidptr, *hptr; int quiet = 0; + domain = NULL; while ((ch = getopt(argc, argv, "g:p:h:n:d:q")) != -1) { switch(ch) { case 'g': @@ -180,22 +181,36 @@ * group information we just stored if necessary. */ while(fgets(readbuf, LINSIZ, pfp)) { - if ((ptr = strchr(readbuf, ':')) == NULL) + /* Ignore comments: ^[ \t]*# */ + for (ptr = readbuf; *ptr != '\0'; ptr++) + if (*ptr != ' ' && *ptr != '\t') + break; + if (*ptr == '#' || *ptr == '\0') + continue; + if ((ptr = strchr(readbuf, ':')) == NULL) { warnx("bad passwd file entry: %s", readbuf); + continue; + } *ptr = '\0'; ptr++; - if ((ptr = strchr(ptr, ':')) == NULL) + if ((ptr = strchr(ptr, ':')) == NULL) { warnx("bad passwd file entry: %s", readbuf); + continue; + } *ptr = '\0'; ptr++; pidptr = ptr; - if ((ptr = strchr(ptr, ':')) == NULL) + if ((ptr = strchr(ptr, ':')) == NULL) { warnx("bad passwd file entry: %s", readbuf); + continue; + } *ptr = '\0'; ptr++; gidptr = ptr; - if ((ptr = strchr(ptr, ':')) == NULL) + if ((ptr = strchr(ptr, ':')) == NULL) { warnx("bad passwd file entry: %s", readbuf); + continue; + } *ptr = '\0'; i = atol(gidptr); %%% P.S. The code still has a lot of bugs. -- Maxim Konovalov, MAcomnet, Internet Dept., system engineer phone: +7 (095) 796-9079, mailto:maxim@macomnet.ru To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210181340.g9IDe53t093122>