1 Upstream-Status: inappropriate
3 From a263cdabad01ba99581b26d1753cd459f2669413 Mon Sep 17 00:00:00 2001
4 From: Corey Minyard <cminyard@mvista.com>
5 Date: Tue, 7 Jun 2011 09:14:19 -0500
6 Subject: [PATCH 19/19] Make sure superblock is clear on allocation
8 Use calloc, not malloc, so the allocated superblock is zero-ed. Also,
9 get rid of some unnecessary casts.
11 genext2fs.c | 6 +++---
12 1 files changed, 3 insertions(+), 3 deletions(-)
14 diff --git a/genext2fs.c b/genext2fs.c
15 index 28ba94f..fab90be 100644
18 @@ -2447,10 +2447,10 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes,
19 fs->nheadblocks = (((nbgroups * sizeof(groupdescriptor))
20 + sizeof(superblock) + (BLOCKSIZE - 1))
22 - fs->sb = (superblock *) malloc(BLOCKSIZE);
23 + fs->sb = calloc(1, BLOCKSIZE);
25 error_msg_and_die("error allocating header memory");
26 - fs->gd = (groupdescriptor *) calloc(fs->nheadblocks - 1, BLOCKSIZE);
27 + fs->gd = calloc(fs->nheadblocks - 1, BLOCKSIZE);
29 error_msg_and_die("error allocating header memory");
31 @@ -2595,7 +2595,7 @@ load_fs(FILE * fh, int swapit, char *fname)
33 /* Read and check the superblock, then read the superblock
34 * and all the group descriptors */
35 - fs->sb = malloc(BLOCKSIZE);
36 + fs->sb = calloc(1, BLOCKSIZE);
38 error_msg_and_die("error allocating header memory");
39 if (fseek(fs->f, BLOCKSIZE, SEEK_SET))