From: Thomas Veerman Date: Mon, 2 Apr 2012 15:16:44 +0000 (+0000) Subject: VFS: fix new signed/unsigned comparisons X-Git-Tag: v3.2.1~598 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.host.html?a=commitdiff_plain;h=b956493367beb6f60edbe09f390ce5b3f3149164;p=minix.git VFS: fix new signed/unsigned comparisons --- diff --git a/servers/vfs/coredump.c b/servers/vfs/coredump.c index b3a9737e6..0fa1bc4d6 100644 --- a/servers/vfs/coredump.c +++ b/servers/vfs/coredump.c @@ -297,13 +297,18 @@ static void dump_segments(struct filp *f, Elf_Phdr phdrs[], int phnum) len = phdrs[i].p_memsz; seg_off = phdrs[i].p_vaddr; - for (off = 0; off < len; off += CLICK_SIZE) { + if (len > LONG_MAX) { + printf("VFS: segment too large to dump, truncating\n"); + len = LONG_MAX; + } + + for (off = 0; off < (off_t) len; off += CLICK_SIZE) { r = sys_vircopy(fp->fp_endpoint, D, (vir_bytes) (seg_off + off), SELF, D, (vir_bytes) buf, (phys_bytes) CLICK_SIZE); - write_buf(f, (char *) buf, (off + CLICK_SIZE <= len) ? + write_buf(f, (char *) buf, (off + CLICK_SIZE <= (off_t) len) ? CLICK_SIZE : (len - off)); } } diff --git a/servers/vfs/exec.c b/servers/vfs/exec.c index de0c22983..0de11270d 100644 --- a/servers/vfs/exec.c +++ b/servers/vfs/exec.c @@ -523,7 +523,8 @@ int replace * pointers are really offsets from the start of stack. * Return true iff the operation succeeded. */ - int offset, a0, a1; + int offset; + vir_bytes a0, a1; size_t old_bytes = *stk_bytes; /* Prepending arg adds at least one string and a zero byte. */ @@ -624,7 +625,8 @@ phys_bytes seg_bytes /* how much is to be transferred? */ assert((seg == T)||(seg == D)); /* Make sure that the file is big enough */ - if (vp->v_size < off+seg_bytes) return(EIO); + if (off + seg_bytes > LONG_MAX) return(EIO); + if ((unsigned long) vp->v_size < off+seg_bytes) return(EIO); if (seg == T) { /* We have to use a copy loop until safecopies support segments */ diff --git a/servers/vfs/proto.h b/servers/vfs/proto.h index 4091438c2..3689c6c29 100644 --- a/servers/vfs/proto.h +++ b/servers/vfs/proto.h @@ -316,7 +316,7 @@ void vmnt_unmap_by_endpt(endpoint_t proc_e); void check_vnode_locks(void); void check_vnode_locks_by_me(struct fproc *rfp); struct vnode *get_free_vnode(void); -struct vnode *find_vnode(int fs_e, int numb); +struct vnode *find_vnode(int fs_e, ino_t inode); void init_vnodes(void); int is_vnode_locked(struct vnode *vp); int lock_vnode(struct vnode *vp, tll_access_t locktype); diff --git a/servers/vfs/select.c b/servers/vfs/select.c index 86dcb6880..3b2712f67 100644 --- a/servers/vfs/select.c +++ b/servers/vfs/select.c @@ -145,7 +145,7 @@ int do_select(void) /* Verify that file descriptors are okay to select on */ for (fd = 0; fd < nfds; fd++) { struct filp *f; - int type, ops; + unsigned int type, ops; /* Because the select() interface implicitly includes file descriptors * you might not want to select on, we have to figure out whether we're @@ -311,7 +311,7 @@ static int is_pipe(struct filp *f) static int is_supported_major(struct filp *f) { /* See if this filp is a handle on a device on which we support select() */ - int m; + unsigned int m; if (!(f && f->filp_vno)) return(FALSE); if ((f->filp_vno->v_mode & I_TYPE) != I_CHAR_SPECIAL) return(FALSE); diff --git a/servers/vfs/utility.c b/servers/vfs/utility.c index 46a578264..dc5a55019 100644 --- a/servers/vfs/utility.c +++ b/servers/vfs/utility.c @@ -44,7 +44,7 @@ inline int copy_name( size_t len, char *dest) if (len <= M3_STRING) { /* Just copy the path from the message */ - int count = 0; + unsigned int count = 0; rpu = &dest[0]; rpm = job_m_in.pathname; /* contained in input message */ for (count = 0; count <= len; count++) diff --git a/servers/vfs/vnode.c b/servers/vfs/vnode.c index 4a9b00efd..14539e89a 100644 --- a/servers/vfs/vnode.c +++ b/servers/vfs/vnode.c @@ -108,7 +108,7 @@ struct vnode *get_free_vnode() /*===========================================================================* * find_vnode * *===========================================================================*/ -struct vnode *find_vnode(int fs_e, int ino) +struct vnode *find_vnode(int fs_e, ino_t ino) { /* Find a specified (FS endpoint and inode number) vnode in the * vnode table */