diff --git a/src/kernel/core/fs/bootfs.c b/src/kernel/core/fs/bootfs.c index b9d7a40b0a..2b7b7b1906 100755 --- a/src/kernel/core/fs/bootfs.c +++ b/src/kernel/core/fs/bootfs.c @@ -742,7 +742,7 @@ bootfs_read_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, struct dirent { struct bootfs_cookie *cookie = _cookie; struct bootfs *fs = _fs; - status_t status; + status_t status = B_OK; TRACE(("bootfs_read_dir(fs_volume = %p vnode = %p, fs_cookie = %p, buffer = %p, bufferSize = %ld, num = %ld)\n",_fs, _vnode, cookie, dirent, bufferSize, *_num)); @@ -750,7 +750,6 @@ bootfs_read_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, struct dirent if (cookie->u.dir.ptr == NULL) { *_num = 0; - status = B_OK; goto err; } @@ -763,11 +762,12 @@ bootfs_read_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, struct dirent goto err; } - status = user_strcpy(dirent->d_name, cookie->u.dir.ptr->name); + status = user_strlcpy(dirent->d_name, cookie->u.dir.ptr->name, bufferSize - sizeof(struct dirent)); if (status < B_OK) goto err; cookie->u.dir.ptr = cookie->u.dir.ptr->dir_next; + status = B_OK; err: mutex_unlock(&fs->lock); diff --git a/src/kernel/core/fs/devfs.c b/src/kernel/core/fs/devfs.c index 4399fe1654..88cdbd5b1c 100755 --- a/src/kernel/core/fs/devfs.c +++ b/src/kernel/core/fs/devfs.c @@ -797,7 +797,7 @@ devfs_read_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, struct dirent { struct devfs_cookie *cookie = _cookie; struct devfs *fs = _fs; - status_t status = 0; + status_t status = B_OK; TRACE(("devfs_read_dir: vnode %p, cookie %p, buffer %p, size %ld\n", _vnode, cookie, dirent, bufferSize)); @@ -808,7 +808,6 @@ devfs_read_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, struct dirent if (cookie->u.dir.ptr == NULL) { *_num = 0; - status = B_OK; goto err; } @@ -821,11 +820,12 @@ devfs_read_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, struct dirent goto err; } - status = user_strcpy(dirent->d_name, cookie->u.dir.ptr->name); - if (status < 0) + status = user_strlcpy(dirent->d_name, cookie->u.dir.ptr->name, bufferSize - sizeof(struct dirent)); + if (status < B_OK) goto err; cookie->u.dir.ptr = cookie->u.dir.ptr->dir_next; + status = B_OK; err: mutex_unlock(&fs->lock); diff --git a/src/kernel/core/fs/rootfs.c b/src/kernel/core/fs/rootfs.c index 2aa40d671a..3ed601f2e3 100755 --- a/src/kernel/core/fs/rootfs.c +++ b/src/kernel/core/fs/rootfs.c @@ -637,7 +637,7 @@ rootfs_read_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, struct dirent { struct rootfs_cookie *cookie = _cookie; struct rootfs *fs = _fs; - status_t status = 0; + status_t status = B_OK; TRACE(("rootfs_read_dir: vnode %p, cookie %p, buffer = %p, bufferSize = %ld, num = %p\n", _vnode, cookie, dirent, bufferSize,_num)); @@ -646,7 +646,6 @@ rootfs_read_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, struct dirent if (cookie->ptr == NULL) { // we're at the end of the directory *_num = 0; - status = B_OK; goto err; } @@ -659,11 +658,12 @@ rootfs_read_dir(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, struct dirent goto err; } - status = user_strcpy(dirent->d_name, cookie->ptr->name); - if (status < 0) + status = user_strlcpy(dirent->d_name, cookie->ptr->name, bufferSize - sizeof(struct dirent)); + if (status < B_OK) goto err; cookie->ptr = cookie->ptr->dir_next; + status = B_OK; err: mutex_unlock(&fs->lock);