This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix off-by one error in a2p
authorPhilip Guenther <guenther@openbsd.org>
Fri, 18 Oct 2013 14:38:55 +0000 (15:38 +0100)
committerDavid Mitchell <davem@iabyn.com>
Fri, 18 Oct 2013 14:38:55 +0000 (15:38 +0100)
The str_gets() function, when encountering a newline character, checked to
see if the previous char was a \ escape. For a blank line, the check would
read the char at the position one before the start of the buffer. There
was a test to avoid this, but it was off-by-one.

AUTHORS
x2p/str.c

diff --git a/AUTHORS b/AUTHORS
index 9fd9eac..b84a6e4 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -930,6 +930,7 @@ Petter Reinholdtsen         <pere@hungry.com>
 Phil Lobbes                    <phil@perkpartners.com>
 Phil Monsen                    <philip.monsen@pobox.com>
 Philip Boulain                 <philip.boulain@smoothwall.net>
+Philip Guenther                 <guenther@openbsd.org>
 Philip Hazel                   <ph10@cus.cam.ac.uk>
 Philip M. Gollucci             <pgollucci@p6m7g8.com>
 Philip Newton                  <pne@cpan.org>
index 86127a0..e12e5e9 100644 (file)
--- a/x2p/str.c
+++ b/x2p/str.c
@@ -200,7 +200,7 @@ str_gets(STR *str, FILE *fp)
     for (;;) {
        while (--cnt >= 0) {
            if ((*bp++ = *ptr++) == newline) {
-               if (bp <= str->str_ptr || bp[-2] != '\\')
+               if (bp <= str->str_ptr + 1 || bp[-2] != '\\')
                    goto thats_all_folks;
                else {
                    line++;