From: David van Moolenbroek Date: Mon, 30 Jul 2012 14:00:22 +0000 (+0000) Subject: libvtreefs: resolve Coverity warnings X-Git-Tag: v3.2.1~418 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=5909c8ba20e813eb6abfd4660340649de1b2079b;p=minix.git libvtreefs: resolve Coverity warnings --- diff --git a/lib/libvtreefs/inode.c b/lib/libvtreefs/inode.c index 6eef9b214..bb0410807 100644 --- a/lib/libvtreefs/inode.c +++ b/lib/libvtreefs/inode.c @@ -211,7 +211,7 @@ struct inode *add_inode(struct inode *parent, char *name, newnode->i_stat = *stat; newnode->i_indexed = nr_indexed_entries; newnode->i_cbdata = cbdata; - strcpy(newnode->i_name, name); + strlcpy(newnode->i_name, name, sizeof(newnode->i_name)); /* Add the inode to the list of children inodes of the parent. */ TAILQ_INSERT_HEAD(&parent->i_children, newnode, i_siblings); diff --git a/lib/libvtreefs/path.c b/lib/libvtreefs/path.c index f2db11792..e46c3f522 100644 --- a/lib/libvtreefs/path.c +++ b/lib/libvtreefs/path.c @@ -114,7 +114,7 @@ static int go_down(struct inode *parent, char *name, struct inode **child) /*===========================================================================* * resolve_link * *===========================================================================*/ -static int resolve_link(struct inode *node, char *pptr, char *tail) +static int resolve_link(struct inode *node, char pptr[PATH_MAX], char *tail) { /* Given a symbolic link, resolve and return the contents of the link. */ @@ -135,9 +135,9 @@ static int resolve_link(struct inode *node, char *pptr, char *tail) if (len + strlen(tail) >= sizeof(path)) return ENAMETOOLONG; - strcat(path, tail); + strlcat(path, tail, sizeof(path)); - strcpy(pptr, path); + strlcpy(pptr, path, PATH_MAX); return OK; } diff --git a/lib/libvtreefs/read.c b/lib/libvtreefs/read.c index 86512885d..d5357622e 100644 --- a/lib/libvtreefs/read.c +++ b/lib/libvtreefs/read.c @@ -45,7 +45,7 @@ int fs_read(void) r = vtreefs_hooks->read_hook(node, pos, &ptr, &len, get_inode_cbdata(node)); - assert(len >= 0 && len <= fs_m_in.REQ_NBYTES); + assert(len <= fs_m_in.REQ_NBYTES); /* Copy the resulting data to user space. */ if (r == OK && len > 0) {