summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-09-09 21:11:36 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-09-09 21:11:36 +0000
commit916bce3a7c3f0d40350786e7ca5d8e55f0bc4f03 (patch)
treebaa2017702fbe3f755415232d285abaab6abe8e2
parentfe041980c81d352adc19aa2933bcce9d801fcc6a (diff)
downloadcoreutils-916bce3a7c3f0d40350786e7ca5d8e55f0bc4f03.tar.xz
(tac_seekable): Store match length in regoff_t, not int. Assume that
negative return values less than -2 represent regoff_t overflow.
-rw-r--r--src/tac.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/tac.c b/src/tac.c
index 1786b76fd..c5fbe24e6 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -255,14 +255,18 @@ tac_seekable (int input_fd, const char *file)
Otherwise, make `match_start' < `G_buffer'. */
if (sentinel_length == 0)
{
- ptrdiff_t i = match_start - G_buffer;
- int ret;
+ size_t i = match_start - G_buffer;
+ regoff_t ri = i;
+ regoff_t range = 1 - ri;
+ regoff_t ret;
- if (! (INT_MIN < i && i <= INT_MAX))
+ if (1 < range)
error (EXIT_FAILURE, 0, _("record too large"));
- ret = re_search (&compiled_separator, G_buffer, i, i - 1, -i, &regs);
- if (ret == -1)
+ if (range == 1
+ || ((ret = re_search (&compiled_separator, G_buffer,
+ i, i - 1, range, &regs))
+ == -1))
match_start = G_buffer - 1;
else if (ret == -2)
{