Skip to content

Commit

Permalink
fix off-by one error in a2p
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Philip Guenther authored and iabyn committed Oct 18, 2013
1 parent 099bebb commit a7ed8fa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion x2p/str.c
Expand Up @@ -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++;
Expand Down

0 comments on commit a7ed8fa

Please sign in to comment.