From 22294bfac809d29e8f83448880b7cac2fbcd6bf9 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Fri, 20 Aug 2010 20:34:44 +0000 Subject: [PATCH] * lib/commonio.c: Make sure there are no NULL pointer dereference. --- ChangeLog | 4 ++++ lib/commonio.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5e68631b..31e2fee7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-08-20 Nicolas François + + * lib/commonio.c: Make sure there are no NULL pointer dereference. + 2010-08-20 Nicolas François * libmisc/remove_tree.c: Ignore snprintf return value. diff --git a/lib/commonio.c b/lib/commonio.c index 38f4d85a..4eae17d1 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -713,6 +713,7 @@ commonio_sort (struct commonio_db *db, int (*cmp) (const void *, const void *)) for (ptr = db->head; (NULL != ptr) #if KEEP_NIS_AT_END + && (NULL != ptr->line) && ('+' != ptr->line[0]) #endif ; @@ -720,7 +721,7 @@ commonio_sort (struct commonio_db *db, int (*cmp) (const void *, const void *)) n++; } #if KEEP_NIS_AT_END - if (NULL != ptr) { + if ((NULL != ptr) && (NULL != ptr->line)) { nis = ptr; } #endif @@ -741,7 +742,10 @@ commonio_sort (struct commonio_db *db, int (*cmp) (const void *, const void *)) #else NULL != ptr; #endif - ptr = ptr->next) { +/*@ -nullderef @*/ + ptr = ptr->next +/*@ +nullderef @*/ + ) { entries[n] = ptr; n++; }