summaryrefslogtreecommitdiffstats
path: root/disk-utils/fsck.minix.c
diff options
context:
space:
mode:
authorKarel Zak2009-10-16 22:08:35 +0200
committerKarel Zak2009-10-17 00:19:23 +0200
commitc326060c2fe3ffbb302e2cbce9e8ae3c4947a652 (patch)
tree94fac855fa7357a0209784ddefbb786566102c27 /disk-utils/fsck.minix.c
parentfdisk: fix strict-aliasing bugs (diff)
downloadkernel-qcow2-util-linux-c326060c2fe3ffbb302e2cbce9e8ae3c4947a652.tar.gz
kernel-qcow2-util-linux-c326060c2fe3ffbb302e2cbce9e8ae3c4947a652.tar.xz
kernel-qcow2-util-linux-c326060c2fe3ffbb302e2cbce9e8ae3c4947a652.zip
fsck.minix: fix strict-aliasing bugs
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/fsck.minix.c')
-rw-r--r--disk-utils/fsck.minix.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c
index 31b5ef6c2..0ce719641 100644
--- a/disk-utils/fsck.minix.c
+++ b/disk-utils/fsck.minix.c
@@ -145,7 +145,8 @@ static char current_name[MAX_DEPTH*(NAME_MAX+1)+1];
static char * inode_buffer = NULL;
#define Inode (((struct minix_inode *) inode_buffer)-1)
#define Inode2 (((struct minix2_inode *) inode_buffer)-1)
-static char super_block_buffer[BLOCK_SIZE];
+
+static char *super_block_buffer;
#define Super (*(struct minix_super_block *)super_block_buffer)
#define INODES ((unsigned long)Super.s_ninodes)
#define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones))
@@ -584,6 +585,11 @@ static void
read_superblock(void) {
if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET))
die(_("seek failed"));
+
+ super_block_buffer = calloc(1, BLOCK_SIZE);
+ if (!super_block_buffer)
+ die(_("unable to alloc buffer for superblock"));
+
if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE))
die(_("unable to read super block"));
if (MAGIC == MINIX_SUPER_MAGIC) {