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++; }