aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-06-28 14:34:41 -0700
committerEric Biggers <ebiggers@google.com>2019-06-28 14:34:41 -0700
commit88438bb2558d2b86c853ae388d2aa12a4bc0a81e (patch)
tree43c3945bd2dad203ad017839b3ca98bae7ff6cd9
parentac3717192cfaa496ae8ffbe1f6b2a02ce88e629c (diff)
downloadfsverity-utils-88438bb2558d2b86c853ae388d2aa12a4bc0a81e.tar.gz
cmd_sign: avoid passing NULL to memcpy()
Technically, memcpy(foo, NULL, 0) has undefined behavior... Signed-off-by: Eric Biggers <ebiggers@google.com>
-rw-r--r--cmd_sign.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/cmd_sign.c b/cmd_sign.c
index fb4d2e5..46798f9 100644
--- a/cmd_sign.c
+++ b/cmd_sign.c
@@ -407,7 +407,8 @@ static bool compute_root_hash(struct filedes *file, u64 file_size,
u64 offset;
bool ok = false;
- memcpy(padded_salt, salt, salt_size);
+ if (salt_size != 0)
+ memcpy(padded_salt, salt, salt_size);
/* Compute number of levels */
for (blocks = DIV_ROUND_UP(file_size, block_size); blocks > 1;