[PATCH] Fix bad typo that sabotates O_TRUNC

ak@muc.de
Fri, 10 Apr 1998 00:53:26 +0200


Hello,

I found a bad typo in 2.1.94 do_open() - O_TRUNC is always ignored because
of an obvious typo (flag&O_TRUNC instead of flags&O_TRUNC). O_TRUNC never
works, because O_ACCMODE is smaller than O_TRUNC.

I renamed the variable to prevent these bugs in the future. Please apply
that ASAP, because it has interesting security implications.

-Andi

--- linux/fs/open.c Fri Mar 27 09:15:15 1998
+++ linux/fs/open.c Fri Apr 10 00:07:02 1998
@@ -622,19 +630,19 @@
struct inode * inode;
struct dentry * dentry;
struct file * f;
- int flag,error;
+ int rwmod,error;

error = -ENFILE;
f = get_empty_filp();
if (!f)
goto out;
- f->f_flags = flag = flags;
- f->f_mode = (flag+1) & O_ACCMODE;
+ f->f_flags = rwmod = flags;
+ f->f_mode = (rwmod+1) & O_ACCMODE;
if (f->f_mode)
- flag++;
- if (flag & O_TRUNC)
- flag |= 2;
- dentry = open_namei(filename,flag,mode);
+ rwmod++;
+ if (flags & O_TRUNC)
+ rwmod |= 2;
+ dentry = open_namei(filename,rwmod,mode);
error = PTR_ERR(dentry);
if (IS_ERR(dentry))
goto cleanup_file;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu