From: Al Viro <viro@ftp.linux.org.uk>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] affs_fill_super() %s abuses
Date: Thu, 15 Jun 2006 12:03:55 +0100 [thread overview]
Message-ID: <20060615110355.GH27946@ftp.linux.org.uk> (raw)
%s is valid only on NUL-terminated arrays, damnit!
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
fs/affs/super.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
02cc7ba4e655dc01773f43e5324986188d42653d
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 4d7e5b1..02aeb22 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -271,6 +271,7 @@ static int affs_fill_super(struct super_
int reserved;
unsigned long mount_flags;
int tmp_flags; /* fix remount prototype... */
+ u8 sig[4];
pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options");
@@ -370,8 +371,9 @@ got_root:
printk(KERN_ERR "AFFS: Cannot read boot block\n");
goto out_error;
}
- chksum = be32_to_cpu(*(__be32 *)boot_bh->b_data);
+ memcpy(sig, boot_bh->b_data, 4);
brelse(boot_bh);
+ chksum = be32_to_cpu(*(__be32 *)sig);
/* Dircache filesystems are compatible with non-dircache ones
* when reading. As long as they aren't supported, writing is
@@ -420,11 +422,17 @@ got_root:
}
if (mount_flags & SF_VERBOSE) {
- chksum = cpu_to_be32(chksum);
- printk(KERN_NOTICE "AFFS: Mounting volume \"%*s\": Type=%.3s\\%c, Blocksize=%d\n",
- AFFS_ROOT_TAIL(sb, root_bh)->disk_name[0],
- AFFS_ROOT_TAIL(sb, root_bh)->disk_name + 1,
- (char *)&chksum,((char *)&chksum)[3] + '0',blocksize);
+ int len = AFFS_ROOT_TAIL(sb, root_bh)->disk_name[0];
+ char name[32];
+
+ if (len > 31)
+ len = 31;
+ memcpy(name, AFFS_ROOT_TAIL(sb, root_bh)->disk_name + 1, len);
+ name[len] = '\0';
+
+ printk(KERN_NOTICE "AFFS: Mounting volume \"%*s\": "
+ "Type=%c%c%c\\%c, Blocksize=%d\n",
+ len, name, sig[0], sig[1], sig[2], sig[3], blocksize);
}
sb->s_flags |= MS_NODEV | MS_NOSUID;
--
1.3.GIT
next reply other threads:[~2006-06-15 11:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-15 11:03 Al Viro [this message]
2006-06-15 11:56 ` [PATCH] affs_fill_super() %s abuses Andreas Schwab
2006-06-15 12:02 ` Al Viro
2006-06-15 12:31 ` Roman Zippel
2006-06-15 12:39 ` Al Viro
2006-06-15 12:40 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060615110355.GH27946@ftp.linux.org.uk \
--to=viro@ftp.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox