From: Thomas Veerman Date: Fri, 25 Jan 2013 11:57:32 +0000 (+0000) Subject: PFS: verify nrbytes X-Git-Tag: v3.2.1~73 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=0968a93748baaeb19add58135e369964846c9e4b;p=minix.git PFS: verify nrbytes --- diff --git a/servers/pfs/read.c b/servers/pfs/read.c index 86a4f0b1e..cbbba89a5 100644 --- a/servers/pfs/read.c +++ b/servers/pfs/read.c @@ -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);