diffutils-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new cmp -i 99999999999999999999 failure


From: Jim Meyering
Subject: new cmp -i 99999999999999999999 failure
Date: Sun, 25 Jun 2023 12:26:00 -0700

Thanks for your recent fixes, Paul.

I was surprised to see your just-added "cmp" test failing, but only on Fedora 
38.
This would report a difference:

  echo a>a;echo b>b; src/cmp -i 99999999999999999999 a b

It's due to a behavior difference in lseek.
I fixed it with the attached, which I've just pushed.

I did not track down whether this is due to a change in glibc or the kernel.

>From 2f053f15c04a4233fa4c5499746a11f693ec7ed6 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@meta.com>
Date: Sun, 25 Jun 2023 12:06:50 -0700
Subject: [PATCH] cmp: avoid new tests/cmp failure

* src/cmp.c (file_position): Set position to EOF by calling lseek
with an offset of 0 and SEEK_END, rather than a SEEK_CURR-relative
offset of the maximum off_t value. The latter would evoke failure on
fedora 38/glibc-2.37/linux 6.2.15-300.fc38.x86_64:
  lseek(3, 9223372036854775807, SEEK_CUR) = -1 EINVAL
The failing test was this (which must now exit 0, but did not):
  echo a>a;echo b>b; src/cmp -i 99999999999999999999 a b
---
 src/cmp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/cmp.c b/src/cmp.c
index 785c391..1e2b70a 100644
--- a/src/cmp.c
+++ b/src/cmp.c
@@ -746,8 +746,9 @@ file_position (int f)
        pos = -EOVERFLOW;
       else
        {
-         pos = lseek (file_desc[f], pos < 0 ? TYPE_MAXIMUM (off_t) : pos,
-                      SEEK_CUR);
+         pos = (pos < 0
+                 ? lseek (file_desc[f], 0, SEEK_END)
+                 : lseek (file_desc[f], pos, SEEK_CUR));
          if (pos < 0)
            pos = -errno;
        }
-- 
2.41.0.191.g6ff334181c


reply via email to

[Prev in Thread] Current Thread [Next in Thread]