From 03880ce6956b42b81060087ad7d6fb1ff8164ac4 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Tue, 19 Dec 2017 00:32:45 +0000 Subject: [PATCH] allocator_thread: add assertion that we get the right response in order to prevent future bugs like the one fixed in cc7bc891ffd9ed1ebcb61d61f36ed02a0e401504 we need to assure that the response is of the same type as the request - if not, some unexpected race condition happened. --- src/allocator_thread.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/allocator_thread.c b/src/allocator_thread.c index 2bcd0d0..f9b2c91 100644 --- a/src/allocator_thread.c +++ b/src/allocator_thread.c @@ -289,6 +289,7 @@ ip_type4 at_get_ip_for_host(char* host, size_t len) { inv: readbuf = ip_type_invalid.addr.v4; } + assert(msg.msgtype == ATM_GETIP); MUTEX_UNLOCK(internal_ips_lock); return readbuf; } @@ -301,6 +302,7 @@ size_t at_get_host_for_ip(ip_type4 ip, char* readbuf) { if((ptrdiff_t) msg.datalen <= 0) res = 0; else res = msg.datalen - 1; } + assert(msg.msgtype == ATM_GETNAME); MUTEX_UNLOCK(internal_ips_lock); return res; }