From faab0349cbf2157f920df35ca982b96228204ae1 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 5 Jun 2006 00:40:01 +0000 Subject: [PATCH] 2037. [func] When unlinking the first or last element in a list check that the list head points to the element to be unlinked. [RT #15959] --- CHANGES | 4 ++++ lib/bind/include/isc/list.h | 8 ++++++-- lib/isc/include/isc/list.h | 10 +++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 6305a7113d..3e032e8eda 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +2037. [func] When unlinking the first or last element in a list + check that the list head points to the element to + be unlinked. [RT #15959] + 2034. [bug] gcc: set -fno-strict-aliasing. [RT #16124] diff --git a/lib/bind/include/isc/list.h b/lib/bind/include/isc/list.h index ad574ac2b5..4e27eb19ba 100644 --- a/lib/bind/include/isc/list.h +++ b/lib/bind/include/isc/list.h @@ -66,12 +66,16 @@ INSIST(LINKED(elt, link));\ if ((elt)->link.next != NULL) \ (elt)->link.next->link.prev = (elt)->link.prev; \ - else \ + else { \ + INSIST((list).tail == (elt)); \ (list).tail = (elt)->link.prev; \ + } \ if ((elt)->link.prev != NULL) \ (elt)->link.prev->link.next = (elt)->link.next; \ - else \ + else { \ + INSIST((list).head == (elt)); \ (list).head = (elt)->link.next; \ + } \ INIT_LINK_TYPE(elt, link, type); \ } while (0) #define UNLINK(list, elt, link) \ diff --git a/lib/isc/include/isc/list.h b/lib/isc/include/isc/list.h index cd5b2cf213..862c41e028 100644 --- a/lib/isc/include/isc/list.h +++ b/lib/isc/include/isc/list.h @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: list.h,v 1.18.2.3 2004/03/09 06:11:57 marka Exp $ */ +/* $Id: list.h,v 1.18.2.4 2006/06/05 00:40:01 marka Exp $ */ #ifndef ISC_LIST_H #define ISC_LIST_H 1 @@ -90,12 +90,16 @@ do { \ if ((elt)->link.next != NULL) \ (elt)->link.next->link.prev = (elt)->link.prev; \ - else \ + else { \ + ISC_INSIST((list).tail == (elt)); \ (list).tail = (elt)->link.prev; \ + } \ if ((elt)->link.prev != NULL) \ (elt)->link.prev->link.next = (elt)->link.next; \ - else \ + else { \ + ISC_INSIST((list).head == (elt)); \ (list).head = (elt)->link.next; \ + } \ (elt)->link.prev = (type *)(-1); \ (elt)->link.next = (type *)(-1); \ } while (0)