From: Florent Bruneau Date: Wed, 10 Sep 2008 16:37:05 +0000 (+0200) Subject: Missing error report, and fix error in binary search. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=1b6ea933129c7a718fc81bedb282a13958a8ea68;p=apps%2Fpfixtools.git Missing error report, and fix error in binary search. Signed-off-by: Florent Bruneau --- diff --git a/postlicyd/rbl.c b/postlicyd/rbl.c index 3f98ee9..3f8c682 100644 --- a/postlicyd/rbl.c +++ b/postlicyd/rbl.c @@ -173,6 +173,9 @@ rbldb_t *rbldb_create(const char *file, bool lock) /* Lookup may perform serveral I/O, so avoid swap. */ db->locked = lock && mlock(db->ips, db->len * sizeof(*(db->ips))) == 0; + if (lock && !db->locked) { + UNIXERR("mlock"); + } if (db->len) { # define QSORT_TYPE uint32_t @@ -207,7 +210,7 @@ bool rbldb_ipv4_lookup(rbldb_t *db, uint32_t ip) int l = 0, r = db->len; while (l < r) { - int i = (r + 1) / 2; + int i = (r + l) / 2; if (db->ips[i] == ip) return true;