]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix return value of tor_fd_seekend.
authorNick Mathewson <nickm@torproject.org>
Wed, 20 Aug 2014 17:48:17 +0000 (13:48 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 20 Aug 2014 17:49:25 +0000 (13:49 -0400)
Previously, we had documented it to return -1 or 0, when in fact
lseek returns -1 or the new position in the file.

This is harmless, since we were only checking for negative values
when we used tor_fd_seekend.

src/common/compat.c

index eb9a70f580b05b4e396395cadd2b1b5e70d625de..278e5c5241b610398dacf9097a54ed9510878966 100644 (file)
@@ -990,14 +990,14 @@ tor_fd_seekend(int fd)
 #ifdef _WIN32
   return _lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
 #else
-  int rc = lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
+  off_t rc = lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
 #ifdef ESPIPE
   /* If we get an error and ESPIPE, then it's a pipe or a socket of a fifo:
    * no need to worry. */
   if (rc < 0 && errno == ESPIPE)
     rc = 0;
 #endif
-  return rc;
+  return (rc < 0) ? -1 : 0;
 #endif
 }