Commit 645e68ed authored by Al Viro's avatar Al Viro

[PATCH] fix osf_getdirents()

Return value of filldir callback is just "should we stop here"; it's
not a usable channel for passing error values (i.e. ->readdir() will
forget anything except "is it non-zero").
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 26904217
...@@ -121,24 +121,29 @@ osf_filldir(void *__buf, const char *name, int namlen, loff_t offset, ...@@ -121,24 +121,29 @@ osf_filldir(void *__buf, const char *name, int namlen, loff_t offset,
if (reclen > buf->count) if (reclen > buf->count)
return -EINVAL; return -EINVAL;
d_ino = ino; d_ino = ino;
if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) {
buf->error = -EOVERFLOW;
return -EOVERFLOW; return -EOVERFLOW;
}
if (buf->basep) { if (buf->basep) {
if (put_user(offset, buf->basep)) if (put_user(offset, buf->basep))
return -EFAULT; goto Efault;
buf->basep = NULL; buf->basep = NULL;
} }
dirent = buf->dirent; dirent = buf->dirent;
put_user(d_ino, &dirent->d_ino); if (put_user(d_ino, &dirent->d_ino) ||
put_user(namlen, &dirent->d_namlen); put_user(namlen, &dirent->d_namlen) ||
put_user(reclen, &dirent->d_reclen); put_user(reclen, &dirent->d_reclen) ||
if (copy_to_user(dirent->d_name, name, namlen) || copy_to_user(dirent->d_name, name, namlen) ||
put_user(0, dirent->d_name + namlen)) put_user(0, dirent->d_name + namlen))
return -EFAULT; goto Efault;
dirent = (void __user *)dirent + reclen; dirent = (void __user *)dirent + reclen;
buf->dirent = dirent; buf->dirent = dirent;
buf->count -= reclen; buf->count -= reclen;
return 0; return 0;
Efault:
buf->error = -EFAULT;
return -EFAULT;
} }
asmlinkage int asmlinkage int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment