From d77e3ddb4d210fc01586f4c776286c4b0f7b6611 Mon Sep 17 00:00:00 2001 From: Jean-Christophe DUBOIS Date: Fri, 3 Oct 2014 20:24:25 +0200 Subject: [PATCH] ITS#7959 Check fstat return value Signed-off-by: Jean-Christophe DUBOIS --- libraries/liblmdb/mdb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 3a86b57f9c..5361e054f7 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -8724,14 +8724,23 @@ mdb_env_copyfd0(MDB_env *env, HANDLE fd) #ifdef WIN32 { LARGE_INTEGER fsize; - GetFileSizeEx(env->me_fd, &fsize); + + if (!GetFileSizeEx(env->me_fd, &fsize)) { + rc = ErrCode(); + goto leave; + } + if (w2 > fsize.QuadPart) w2 = fsize.QuadPart; } #else { struct stat st; - fstat(env->me_fd, &st); + + if ((rc = fstat(env->me_fd, &st))) { + goto leave; + } + if (w2 > (size_t)st.st_size) w2 = st.st_size; } -- 2.39.5