diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-12-12 03:22:36 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-12-12 03:22:36 +0000 |
commit | 43854a4be1a65eeb3f4aaefd2b546e2a1aa3b4da (patch) | |
tree | 5e434a43c02c108e63bbbbfccbead2feda9a3a1b /usr.bin/sed | |
parent | b8d87a4c661405c26ad138c1a51b2cc3247cdd4b (diff) |
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')
-rw-r--r-- | usr.bin/sed/process.c | 9 |
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) |