summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getcap.c
diff options
context:
space:
mode:
authorthomas <thomas@FreeBSD.org>2003-01-02 10:19:43 +0000
committerthomas <thomas@FreeBSD.org>2003-01-02 10:19:43 +0000
commitc35e5c982ee6f57ac0459e221871447bbb663584 (patch)
tree6a669dd09851c48b9066497f33bec4db9af498e8 /lib/libc/gen/getcap.c
parent8fa3036bdb3be790eaa5e1a4ffb8f33b84d973d4 (diff)
downloadFreeBSD-src-c35e5c982ee6f57ac0459e221871447bbb663584.zip
FreeBSD-src-c35e5c982ee6f57ac0459e221871447bbb663584.tar.gz
In cgetmatch(3), return -1 if a NULL or 0-length name parameter is used.
This situation most notably arises in chkprintcap, when a /etc/printcap entry has an empty rp= attribute. In that case, cgetmatch would enter an infinite loop if any entry in the file has multiple names. This causes lpd to hang at boot time on 5.0-DP2 when both conditions are met (:rp=: and multiple names -- not necessarily on the same entry). Reviewed by: roberto
Diffstat (limited to 'lib/libc/gen/getcap.c')
-rw-r--r--lib/libc/gen/getcap.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c
index 3dbcd37..af05113 100644
--- a/lib/libc/gen/getcap.c
+++ b/lib/libc/gen/getcap.c
@@ -577,6 +577,9 @@ cgetmatch(const char *buf, const char *name)
{
const char *np, *bp;
+ if (name == NULL || *name == '\0')
+ return -1;
+
/*
* Start search at beginning of record.
*/
OpenPOWER on IntegriCloud