]> www.infradead.org Git - mtd-utils.git/commitdiff
Fix uninitialized buffers
authorDaniel Walter <dwalter@sigma-star.at>
Wed, 31 Aug 2016 08:06:28 +0000 (10:06 +0200)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Thu, 17 Nov 2016 10:36:56 +0000 (11:36 +0100)
Uninitialized buffers lead to failing
unittests, since padding was not set to 0.
Additionally this stops valgrind from complaining as well.

Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
lib/libmtd.c

index ff1180646556636393894e478b3f98f1be47d5e0..8c0157e176c4b4053d9c7bfb3279df38cd37deab 100644 (file)
@@ -252,6 +252,7 @@ static int read_pos_ll(const char *file, long long *value)
 {
        int fd, rd;
        char buf[50];
+       memset(buf, 0, 50);
 
        fd = open(file, O_RDONLY | O_CLOEXEC);
        if (fd == -1)
@@ -1135,6 +1136,7 @@ int mtd_write(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb,
        int ret;
        off_t seek;
        struct mtd_write_req ops;
+       memset(&ops, 0, sizeof(ops));
 
        ret = mtd_valid_erase_block(mtd, eb);
        if (ret)
@@ -1208,6 +1210,8 @@ int do_oob_op(libmtd_t desc, const struct mtd_dev_info *mtd, int fd,
        unsigned long long max_offs;
        const char *cmd64_str, *cmd_str;
        struct libmtd *lib = (struct libmtd *)desc;
+       memset(&oob64, 0, sizeof(oob64));
+       memset(&oob, 0, sizeof(oob));
 
        if (cmd64 ==  MEMREADOOB64) {
                cmd64_str = "MEMREADOOB64";