summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed/process.c
diff options
context:
space:
mode:
authorjsg <jsg@openbsd.org>2014-12-12 03:22:35 +0000
committerjsg <jsg@openbsd.org>2014-12-12 03:22:35 +0000
commit194de1b658e7d56a8c3e12ac40622f5754729bcb (patch)
tree5163baf5bec44b52c3b2f29181aceaa5d58bdcd4 /usr.bin/sed/process.c
parentsysctl_proc_vmmap(): Allow retrieving "self" VM mapping without privilege. (diff)
downloadwireguard-openbsd-194de1b658e7d56a8c3e12ac40622f5754729bcb.tar.xz
wireguard-openbsd-194de1b658e7d56a8c3e12ac40622f5754729bcb.zip
Rework the pointer swap in the 'P' command to make the intent
clearer and avoid a crash on 'g;P' found by Sebastien Marie with the afl fuzzer.
Diffstat (limited to 'usr.bin/sed/process.c')
-rw-r--r--usr.bin/sed/process.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c
index c5e21705230..dee318952da 100644
--- a/usr.bin/sed/process.c
+++ b/usr.bin/sed/process.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process.c,v 1.20 2014/12/01 06:37:25 deraadt Exp $ */
+/* $OpenBSD: process.c,v 1.21 2014/12/12 03:22:35 jsg Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
@@ -184,10 +184,11 @@ redirect:
(p = memchr(ps, '\n', psl - 1)) != NULL) {
oldpsl = psl;
psl = (p + 1) - ps;
- }
- OUT(ps);
- if (p != NULL)
+ OUT(ps);
psl = oldpsl;
+ } else {
+ OUT(ps);
+ }
break;
case 'q':
if (!nflag && !pd)