summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@penguin.transmeta.com>2002-12-02 22:47:22 -0800
committerLinus Torvalds <torvalds@home.transmeta.com>2002-12-02 22:47:22 -0800
commit7c2c01bdb463d8be9cf2b48257191ff229a133aa (patch)
treea3c9aef2812f6a39080f0d453790612367e102dd
parentd618d88d7509508d4a7c30594134e9fba625e7ad (diff)
Fix getdents64() offset saving bug from -mm merge.
Make old 32-bit getdents() look more like the updated getdents64 for maintainability.
-rw-r--r--fs/readdir.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/fs/readdir.c b/fs/readdir.c
index 948bcbe08d79..526a3ad76b5f 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -134,13 +134,13 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
return -EINVAL;
dirent = buf->previous;
if (dirent)
- put_user(offset, &dirent->d_off);
+ __put_user(offset, &dirent->d_off);
dirent = buf->current_dir;
buf->previous = dirent;
- put_user(ino, &dirent->d_ino);
- put_user(reclen, &dirent->d_reclen);
+ __put_user(ino, &dirent->d_ino);
+ __put_user(reclen, &dirent->d_reclen);
copy_to_user(dirent->d_name, name, namlen);
- put_user(0, dirent->d_name + namlen);
+ __put_user(0, dirent->d_name + namlen);
((char *) dirent) += reclen;
buf->current_dir = dirent;
buf->count -= reclen;
@@ -154,6 +154,10 @@ asmlinkage long sys_getdents(unsigned int fd, void * dirent, unsigned int count)
struct getdents_callback buf;
int error;
+ error = -EFAULT;
+ if (!access_ok(VERIFY_WRITE, dirent, count))
+ goto out;
+
error = -EBADF;
file = fget(fd);
if (!file)
@@ -211,12 +215,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
if (reclen > buf->count)
return -EINVAL;
dirent = buf->previous;
- if (dirent)
+ if (dirent) {
if (__put_user(offset, &dirent->d_off))
goto efault;
- else
- if (__put_user(0, &dirent->d_off))
- goto efault;
+ }
dirent = buf->current_dir;
buf->previous = dirent;
if (__put_user(ino, &dirent->d_ino))