From: Jean-Christophe DUBOIS Date: Fri, 3 Oct 2014 18:24:25 +0000 (+0200) Subject: ITS#7959 Check fstat return value X-Git-Tag: LMDB_0.9.15~57 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=042e76685e98eb676d91094423490200ff2b7d07;p=openldap ITS#7959 Check fstat return value Signed-off-by: Jean-Christophe DUBOIS --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index cfa24bf0db..63445ce7af 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -8692,14 +8692,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; }