]> Zhao Yanbai Git Server - minix.git/commitdiff
lseek should not yield a negative file position
authorThomas Veerman <thomas@minix3.org>
Mon, 16 Jan 2012 15:09:55 +0000 (15:09 +0000)
committerThomas Veerman <thomas@minix3.org>
Thu, 19 Jan 2012 16:48:01 +0000 (16:48 +0000)
servers/avfs/open.c

index a236107fdff5ab4716ddc79de7b09b4cdefc5171..e3cbf44707154f112e197d02beeba6a978c7a9b6 100644 (file)
@@ -612,9 +612,11 @@ PUBLIC int do_lseek()
        newpos = sub64ul(pos, -offset);
 
   /* Check for overflow. */
-  if (ex64hi(newpos) != 0)
-       r = EINVAL;
-  else {
+  if (ex64hi(newpos) != 0) {
+       r = EOVERFLOW;
+  } else if ((off_t) ex64lo(newpos) < 0) { /* no negative file size */
+       r = EOVERFLOW;
+  } else {
        rfilp->filp_pos = newpos;
 
        /* insert the new position into the output message */