bug-gnulib
[Top][All Lists]
Advanced

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

Re: fseeko bug


From: Larry Jones
Subject: Re: fseeko bug
Date: Thu, 10 Jan 2008 13:27:40 -0000

Eric Blake writes:
> 
> maybe it's at least worth adding a compile-time assertion that sizeof(off_t)
> ==sizeof(long) when !HAVE_FSEEKO.

Since I actually have a platform where that's not the case, I'd prefer a
run-time test that only objects when there's an actual problem:

--- fseeko.c.gnulib     Fri Dec 14 14:17:35 2007
+++ fseeko.c    Fri Dec 14 14:19:17 2007
@@ -28,8 +28,11 @@
 # undef fseek
 # define fseeko fseek
 
-# include <verify.h>
-verify (sizeof (off_t) == sizeof (long));
+# include <limits.h>
+# include <errno.h>
+# ifndef EOVERFLOW
+#  define EOVERFLOW EINVAL
+# endif
 #endif
 
 int
@@ -121,6 +124,13 @@
          return 0;
        }
     }
+#if !HAVE_FSEEKO
+  else if (offset < LONG_MIN || offset > LONG_MAX)
+    {
+      errno = EOVERFLOW;
+      return -1;
+    }
+#endif
   else
     return fseeko (fp, offset, whence);
 }

-Larry Jones

Everything's gotta have rules, rules, rules! -- Calvin




reply via email to

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