Date: Wed, 26 May 1999 12:26:22 -0400 (EDT) From: adrian@ubergeeks.com To: FreeBSD-gnats-submit@freebsd.org Subject: bin/11896: argument checking on cap_mkdb Message-ID: <199905261626.MAA03104@terrafirma.cstone.net>
next in thread | raw e-mail | index | archive | help
>Number: 11896 >Category: bin >Synopsis: cap_mkdb dumps core when non-files passed as arguments >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed May 26 09:30:01 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Adrian Filipi-Martin >Release: FreeBSD 3.2-RELEASE i386 >Organization: Ubergeeks Consulting >Environment: 3.2-RLEASE as built locally and installed on about 5/17. >Description: If passed a non-file, e.g. a directory, as an argument, cap_mkdb will segfault and dump core. >How-To-Repeat: cap_mkdb /etc >Fix: Apply this patch. Note that I consider a FIFO ok, because sometimes I use the <(command|filter) idiom to feed processed data to commands as file arguments. --- cap_mkdb.c.orig Sun Dec 6 17:58:12 1998 +++ cap_mkdb.c Wed May 26 12:04:20 1999 @@ -75,6 +75,7 @@ char *argv[]; { int c; + const char *const progname = strrchr(argv[0], '/') + 1; capname = NULL; while ((c = getopt(argc, argv, "f:v")) != -1) { @@ -95,6 +96,18 @@ if (*argv == NULL) usage(); + else { + char **p = argv; + do { + struct stat sb; + if (stat(*p, &sb) == -1) + err(1, (char *)NULL); + if (sb.st_mode & (S_IFREG|S_IFIFO)) + continue; + fprintf(stderr, "%s: %s, not a regular file", progname, *p); + exit(1); + } while (*++p); + } /* * The database file is the first argument if no name is specified. >Release-Note: >Audit-Trail: >Unformatted: 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?199905261626.MAA03104>