summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed/process.c
diff options
context:
space:
mode:
authorfanf <fanf@FreeBSD.org>2003-06-05 12:10:19 +0000
committerfanf <fanf@FreeBSD.org>2003-06-05 12:10:19 +0000
commite503a716d1fa6dda08fbf59b2555ce8a813dc034 (patch)
tree090a0f027fcb7094e8465d221645b6080d112e48 /usr.bin/sed/process.c
parent74c170f9c2d9b7611d6e42962492e8d8d718c5f0 (diff)
downloadFreeBSD-src-e503a716d1fa6dda08fbf59b2555ce8a813dc034.zip
FreeBSD-src-e503a716d1fa6dda08fbf59b2555ce8a813dc034.tar.gz
Do not dribble zero bytes into the output, by replacing an obfuscated if
whose true and false clauses were equivalent with a check that we are not about to stumble off the end of the line. Reported by: peter Pointy hat to: fanf
Diffstat (limited to 'usr.bin/sed/process.c')
-rw-r--r--usr.bin/sed/process.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c
index f7d730d..d0fac86 100644
--- a/usr.bin/sed/process.c
+++ b/usr.bin/sed/process.c
@@ -362,10 +362,7 @@ substitute(cp)
slen -= match[0].rm_eo;
lastempty = 0;
} else {
- if (match[0].rm_so == 0)
- cspace(&SS, s, match[0].rm_so + 1,
- APPEND);
- else
+ if (match[0].rm_so < slen)
cspace(&SS, s + match[0].rm_so, 1,
APPEND);
s += match[0].rm_so + 1;
OpenPOWER on IntegriCloud