|
|
b1d0b3 |
diff -up db-5.3.21/src/env/env_region.c.zero-region db-5.3.21/src/env/env_region.c
|
|
|
b1d0b3 |
--- db-5.3.21/src/env/env_region.c.zero-region 2012-05-11 19:57:53.000000000 +0200
|
|
|
b1d0b3 |
+++ db-5.3.21/src/env/env_region.c 2017-09-06 08:50:45.310276385 +0200
|
|
|
b1d0b3 |
@@ -1060,6 +1060,7 @@ __env_region_attach(env, infop, init, ma
|
|
|
b1d0b3 |
REGION *rp;
|
|
|
b1d0b3 |
int ret;
|
|
|
b1d0b3 |
char buf[sizeof(DB_REGION_FMT) + 20];
|
|
|
b1d0b3 |
+ struct stat st;
|
|
|
b1d0b3 |
|
|
|
b1d0b3 |
/*
|
|
|
b1d0b3 |
* Find or create a REGION structure for this region. If we create
|
|
|
b1d0b3 |
@@ -1090,6 +1091,14 @@ __env_region_attach(env, infop, init, ma
|
|
|
b1d0b3 |
if ((ret = __env_sys_attach(env, infop, rp)) != 0)
|
|
|
b1d0b3 |
goto err;
|
|
|
b1d0b3 |
|
|
|
b1d0b3 |
+ /* Check the size of the underlying file */
|
|
|
b1d0b3 |
+ if (infop->fhp != NULL && F_ISSET(infop->fhp, DB_FH_OPENED) &&
|
|
|
b1d0b3 |
+ infop->fhp->fd != -1 && fstat(infop->fhp->fd, &st) != -1 &&
|
|
|
b1d0b3 |
+ st.st_size == 0) {
|
|
|
b1d0b3 |
+ ret = DB_RUNRECOVERY;
|
|
|
b1d0b3 |
+ goto err;
|
|
|
b1d0b3 |
+ }
|
|
|
b1d0b3 |
+
|
|
|
b1d0b3 |
/*
|
|
|
b1d0b3 |
* Fault the pages into memory. Note, do this BEFORE we initialize
|
|
|
b1d0b3 |
* anything because we're writing pages in created regions, not just
|
|
|
b1d0b3 |
diff -up db-5.3.21/src/os/os_map.c.zero-region db-5.3.21/src/os/os_map.c
|
|
|
b1d0b3 |
--- db-5.3.21/src/os/os_map.c.zero-region 2012-05-11 19:57:54.000000000 +0200
|
|
|
b1d0b3 |
+++ db-5.3.21/src/os/os_map.c 2017-09-06 08:49:39.144546552 +0200
|
|
|
b1d0b3 |
@@ -265,6 +265,9 @@ __os_detach(env, infop, destroy)
|
|
|
b1d0b3 |
dbenv = env->dbenv;
|
|
|
b1d0b3 |
|
|
|
b1d0b3 |
rp = infop->rp;
|
|
|
b1d0b3 |
+ /* Do not touch the region information if it no longer exists */
|
|
|
b1d0b3 |
+ if (rp == NULL)
|
|
|
b1d0b3 |
+ return EINVAL;
|
|
|
b1d0b3 |
|
|
|
b1d0b3 |
/* If the user replaced the unmap call, call through their interface. */
|
|
|
b1d0b3 |
if (DB_GLOBAL(j_region_unmap) != NULL)
|