diff options
| -rw-r--r-- | fs/cramfs/inode.c | 11 | ||||
| -rw-r--r-- | include/linux/cramfs_fs.h | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 3d194a2be3f5..5c817bd08389 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c | |||
| @@ -258,12 +258,21 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 258 | 258 | ||
| 259 | /* Do sanity checks on the superblock */ | 259 | /* Do sanity checks on the superblock */ |
| 260 | if (super.magic != CRAMFS_MAGIC) { | 260 | if (super.magic != CRAMFS_MAGIC) { |
| 261 | /* check for wrong endianess */ | ||
| 262 | if (super.magic == CRAMFS_MAGIC_WEND) { | ||
| 263 | if (!silent) | ||
| 264 | printk(KERN_ERR "cramfs: wrong endianess\n"); | ||
| 265 | goto out; | ||
| 266 | } | ||
| 267 | |||
| 261 | /* check at 512 byte offset */ | 268 | /* check at 512 byte offset */ |
| 262 | mutex_lock(&read_mutex); | 269 | mutex_lock(&read_mutex); |
| 263 | memcpy(&super, cramfs_read(sb, 512, sizeof(super)), sizeof(super)); | 270 | memcpy(&super, cramfs_read(sb, 512, sizeof(super)), sizeof(super)); |
| 264 | mutex_unlock(&read_mutex); | 271 | mutex_unlock(&read_mutex); |
| 265 | if (super.magic != CRAMFS_MAGIC) { | 272 | if (super.magic != CRAMFS_MAGIC) { |
| 266 | if (!silent) | 273 | if (super.magic == CRAMFS_MAGIC_WEND && !silent) |
| 274 | printk(KERN_ERR "cramfs: wrong endianess\n"); | ||
| 275 | else if (!silent) | ||
| 267 | printk(KERN_ERR "cramfs: wrong magic\n"); | 276 | printk(KERN_ERR "cramfs: wrong magic\n"); |
| 268 | goto out; | 277 | goto out; |
| 269 | } | 278 | } |
diff --git a/include/linux/cramfs_fs.h b/include/linux/cramfs_fs.h index 1dba681e428d..3be4e5a27d82 100644 --- a/include/linux/cramfs_fs.h +++ b/include/linux/cramfs_fs.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
| 5 | 5 | ||
| 6 | #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */ | 6 | #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */ |
| 7 | #define CRAMFS_MAGIC_WEND 0x453dcd28 /* magic number with the wrong endianess */ | ||
| 7 | #define CRAMFS_SIGNATURE "Compressed ROMFS" | 8 | #define CRAMFS_SIGNATURE "Compressed ROMFS" |
| 8 | 9 | ||
| 9 | /* | 10 | /* |
