]> Zhao Yanbai Git Server - minix.git/commitdiff
PFS: verify nrbytes
authorThomas Veerman <thomas@minix3.org>
Fri, 25 Jan 2013 11:57:32 +0000 (11:57 +0000)
committerThomas Veerman <thomas@minix3.org>
Fri, 25 Jan 2013 17:03:06 +0000 (17:03 +0000)
servers/pfs/read.c

index 86a4f0b1eba77ca13d06d050ec9285b8e09d09b6..cbbba89a59e772a0c1e8965bf2e40e9294717ecb 100644 (file)
@@ -36,7 +36,7 @@ int fs_readwrite(message *fs_m_in, message *fs_m_out)
   nrbytes = (unsigned) fs_m_in->REQ_NBYTES;
 
   /* We can't read beyond the max file position */
-  if (nrbytes > MAX_FILE_POS) return(EFBIG);
+  if (nrbytes > PIPE_BUF) return(EFBIG);
 
   /* Mark inode in use */
   if ((get_inode(rip->i_dev, rip->i_num)) == NULL) return(err_code);
@@ -48,7 +48,7 @@ int fs_readwrite(message *fs_m_in, message *fs_m_out)
         * be beyond max signed value (i.e., MAX_FILE_POS).
         */
        position = rip->i_size;
-       if (position > PIPE_BUF - (signed) nrbytes) {
+       if ((unsigned) position + nrbytes > PIPE_BUF) {
                put_inode(rip);
                put_block(rip->i_dev, rip->i_num);
                return(EFBIG);