From 7617cce0c6f2abe5f083156405494d8e84630f4b Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Wed, 27 Feb 2019 23:26:15 +0300 Subject: [PATCH] mdbx-tools: fix Coverity warning (paranoia). Change-Id: I3ff33a9eb2c58fe601566fd4101f9c95d76d29de --- src/tools/mdbx_load.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tools/mdbx_load.c b/src/tools/mdbx_load.c index 2458b0e2..9789e83a 100644 --- a/src/tools/mdbx_load.c +++ b/src/tools/mdbx_load.c @@ -431,7 +431,13 @@ int main(int argc, char *argv[]) { goto env_close; } - kbuf.iov_len = mdbx_env_get_maxkeysize(env) * 2 + 2; + kbuf.iov_len = mdbx_env_get_maxkeysize(env); + if (kbuf.iov_len >= SIZE_MAX / 4) { + fprintf(stderr, "mdbx_env_get_maxkeysize failed, returns %zu\n", + kbuf.iov_len); + goto env_close; + } + kbuf.iov_len = (kbuf.iov_len + 1) * 2; kbuf.iov_base = malloc(kbuf.iov_len * 2); k0buf.iov_len = kbuf.iov_len; k0buf.iov_base = (char *)kbuf.iov_base + kbuf.iov_len;