summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpd
diff options
context:
space:
mode:
authormestre <mestre@openbsd.org>2019-11-08 07:26:38 +0000
committermestre <mestre@openbsd.org>2019-11-08 07:26:38 +0000
commitb00bff5ef5bb237eda5a2f00280b9cadae2b3e99 (patch)
tree5be8bd472556a2157c2712c1915e582b8c92bdd6 /usr.sbin/lpd
parentconvert interface address change hooks to tasks and a task_list. (diff)
downloadwireguard-openbsd-b00bff5ef5bb237eda5a2f00280b9cadae2b3e99.tar.xz
wireguard-openbsd-b00bff5ef5bb237eda5a2f00280b9cadae2b3e99.zip
fix bogus pointer/double free crash, when /etc/printcap db file is not present,
by adding a missing check for the return value -1 on both cgetfirst(3) and cgetnext(3) OK millert@ deraadt@
Diffstat (limited to 'usr.sbin/lpd')
-rw-r--r--usr.sbin/lpd/lp.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/lpd/lp.c b/usr.sbin/lpd/lp.c
index 0142cc80d02..adcfb32d0c9 100644
--- a/usr.sbin/lpd/lp.c
+++ b/usr.sbin/lpd/lp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lp.c,v 1.1.1.1 2018/04/27 16:14:36 eric Exp $ */
+/* $OpenBSD: lp.c,v 1.2 2019/11/08 07:26:38 mestre Exp $ */
/*
* Copyright (c) 2017 Eric Faurot <eric@openbsd.org>
@@ -116,15 +116,15 @@ lp_scanprinters(struct lp_printer *lp)
cgetclose();
scanning = 0;
return 0;
- }
- else if (r == 1) {
+ } else if (r == 1) {
memset(lp, 0, sizeof(*lp));
r = readent(lp, buf);
free(buf);
if (r == -2)
goto fail;
return 1;
- }
+ } else if (r == -1)
+ fatal("cannot open %s", _PATH_PRINTCAP);
else if (r == -2)
errno = ELOOP; /* potential reference loop */