* CID 2195: sizeof() was used on the buffer pointer instead of the type.
* Use strlcpy() instead of memcpy() to ensure that the dirent is properly terminated. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39954 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4462c768e6
commit
6b81e70656
@ -164,12 +164,13 @@ exit:
|
||||
}
|
||||
|
||||
status_t
|
||||
fs_readdir( fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf, size_t bufsize, uint32 *num )
|
||||
fs_readdir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf,
|
||||
size_t bufsize, uint32 *num)
|
||||
{
|
||||
nspace *ns = (nspace*)_vol->private_volume;
|
||||
vnode *node = (vnode*)_node->private_node;
|
||||
dircookie *cookie = (dircookie*)_cookie;
|
||||
uint32 nameLength = bufsize - sizeof(buf) + 1, realLen;
|
||||
uint32 nameLength = bufsize - sizeof(struct dirent), realLen;
|
||||
int result = B_NO_ERROR;
|
||||
ntfs_inode *ni=NULL;
|
||||
|
||||
@ -196,11 +197,11 @@ fs_readdir( fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf,
|
||||
|
||||
result = ntfs_readdir(ni, &cookie->pos, cookie, (ntfs_filldir_t)_ntfs_dirent_filler);
|
||||
|
||||
realLen = nameLength>255?255:nameLength;
|
||||
realLen = nameLength > 255 ? 255 : nameLength;
|
||||
buf->d_dev = ns->id;
|
||||
buf->d_ino = cookie->ino;
|
||||
memcpy(buf->d_name,cookie->name, realLen+1);
|
||||
buf->d_reclen = sizeof(buf) + realLen - 1;
|
||||
strlcpy(buf->d_name, cookie->name, realLen + 1);
|
||||
buf->d_reclen = sizeof(struct dirent) + realLen;
|
||||
|
||||
if(result==0)
|
||||
cookie->last = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user