From owner-freebsd-bugs Fri Oct 18 6:40:10 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9DA8F37B401 for ; Fri, 18 Oct 2002 06:40:06 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id DD8D743E6A for ; Fri, 18 Oct 2002 06:40:05 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g9IDe5x3093237 for ; Fri, 18 Oct 2002 06:40:05 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g9IDe53t093122; Fri, 18 Oct 2002 06:40:05 -0700 (PDT) Date: Fri, 18 Oct 2002 06:40:05 -0700 (PDT) Message-Id: <200210181340.g9IDe53t093122@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Maxim Konovalov Subject: bin/39671 Reply-To: Maxim Konovalov Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/39671; it has been noted by GNATS. From: Maxim Konovalov To: bug-followup@freebsd.org Cc: Lyndon Nerenberg 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