Re: lseek/llseek allows the negative offset

From: Andrea Arcangeli (andrea@suse.de)
Date: Sun Nov 19 2000 - 20:56:25 EST


On Sat, Nov 18, 2000 at 05:20:34PM -0800, H . J . Lu wrote:
> --- linux/fs/proc/mem.c.lseek Tue Jan 4 10:12:23 2000
> +++ linux/fs/proc/mem.c Sat Nov 18 17:19:28 2000
> @@ -196,14 +196,17 @@ static long long mem_lseek(struct file *
> {
> switch (orig) {
> case 0:
> - file->f_pos = offset;
> - return file->f_pos;
> + break;
> case 1:
> - file->f_pos += offset;
> - return file->f_pos;
> + offset += file->f_pos;
> + break;
> default:
> return -EINVAL;
> }
> + if (offset < 0)
> + return -EINVAL;
> + file->f_pos = offset;
> + return offset;
> }

This looks fine to me.

Andrea
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Nov 23 2000 - 21:00:18 EST