aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Walter <dwalter@sigma-star.at>2016-08-31 10:06:28 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2016-11-17 11:36:56 +0100
commit24ba171570a1482bdae8e3a5f1a8f40bcef2b20d (patch)
treed092bc432208b232a6238fb65bd48d4fb571629b
parent6db431d627f707a3bcd820a2bc32e2a2689c3185 (diff)
Fix uninitialized buffers
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>
-rw-r--r--lib/libmtd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/libmtd.c b/lib/libmtd.c
index ff11806..8c0157e 100644
--- a/lib/libmtd.c
+++ b/lib/libmtd.c
@@ -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";