=================================================================== RCS file: /cvs/mandoc/dbm_map.c,v retrieving revision 1.4 retrieving revision 1.7 diff -u -p -r1.4 -r1.7 --- mandoc/dbm_map.c 2016/08/22 16:07:16 1.4 +++ mandoc/dbm_map.c 2016/10/22 10:09:27 1.7 @@ -1,4 +1,4 @@ -/* $Id: dbm_map.c,v 1.4 2016/08/22 16:07:16 schwarze Exp $ */ +/* $Id: dbm_map.c,v 1.7 2016/10/22 10:09:27 schwarze Exp $ */ /* * Copyright (c) 2016 Ingo Schwarze * @@ -100,8 +100,8 @@ dbm_map(const char *fname) } max_offset = be32toh(*dbm_getint(3)) + sizeof(int32_t); if (st.st_size != max_offset) { - warnx("dbm_map(%s): Inconsistent file size %llu (expected %d)", - fname, st.st_size, max_offset); + warnx("dbm_map(%s): Inconsistent file size %lld (expected %d)", + fname, (long long)st.st_size, max_offset); errno = EFTYPE; goto fail; } @@ -143,7 +143,11 @@ void * dbm_get(int32_t offset) { offset = be32toh(offset); - if (offset < 0 || offset >= max_offset) { + if (offset < 0) { + warnx("dbm_get: Database corrupt: offset %d", offset); + return NULL; + } + if (offset >= max_offset) { warnx("dbm_get: Database corrupt: offset %d > %d", offset, max_offset); return NULL;