From 467e53f5cc713a219db94807b5ad29ae82c47f2c Mon Sep 17 00:00:00 2001 From: schwarze Date: Tue, 30 Aug 2016 21:36:54 +0000 Subject: [PATCH] less confusing warning message about negative offsets --- usr.bin/mandoc/dbm_map.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/usr.bin/mandoc/dbm_map.c b/usr.bin/mandoc/dbm_map.c index ce1e0660b76..875d6326523 100644 --- a/usr.bin/mandoc/dbm_map.c +++ b/usr.bin/mandoc/dbm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dbm_map.c,v 1.2 2016/08/22 16:05:56 schwarze Exp $ */ +/* $OpenBSD: dbm_map.c,v 1.3 2016/08/30 21:36:54 schwarze Exp $ */ /* * Copyright (c) 2016 Ingo Schwarze * @@ -133,7 +133,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; -- 2.20.1