aboutsummaryrefslogtreecommitdiff
path: root/src/mmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mmap.c')
-rw-r--r--src/mmap.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mmap.c b/src/mmap.c
index fd8a72b..9a7d400 100644
--- a/src/mmap.c
+++ b/src/mmap.c
@@ -233,7 +233,12 @@ _gdbm_mapped_remap (GDBM_FILE dbf, off_t size, int flag)
dbf->mapped_pos += dbf->mapped_off;
dbf->mapped_off = 0;
}
-
+ if (pos > file_size)
+ {
+ errno = EINVAL;
+ GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
+ return -1;
+ }
return _gdbm_internal_remap (dbf, size);
}
@@ -271,6 +276,10 @@ _gdbm_mapped_read (GDBM_FILE dbf, void *buffer, size_t len)
{
int rc;
+ if (dbf->need_recovery)
+ return -1;
+
+ /* Disable memory mapping and retry */
dbf->memory_mapping = FALSE;
if (lseek (dbf->desc, pos, SEEK_SET) != pos)
return total > 0 ? total : -1;
@@ -321,6 +330,9 @@ _gdbm_mapped_write (GDBM_FILE dbf, void *buffer, size_t len)
{
int rc;
+ if (dbf->need_recovery)
+ return -1;
+
dbf->memory_mapping = FALSE;
if (lseek (dbf->desc, pos, SEEK_SET) != pos)
return total > 0 ? total : -1;

Return to:

Send suggestions and report system problems to the System administrator.