From: nekral-guest Date: Sat, 25 Apr 2009 13:41:52 +0000 (+0000) Subject: * lib/commonio.c: Do not assumes eptr is always notnull. X-Git-Tag: 4.1.4~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71f7f777ec9ccf9241fdcc7522993a212ba1a938;p=shadow * lib/commonio.c: Do not assumes eptr is always notnull. Updated splint annotations. --- diff --git a/ChangeLog b/ChangeLog index 3a087c8c..ed31980f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2009-04-25 Nicolas François * lib/commonio.h, lib/commonio.c: Added splint annotations. + * lib/commonio.c: Do not assumes eptr is always notnull. 2009-04-25 Nicolas François diff --git a/lib/commonio.c b/lib/commonio.c index d9966126..bedf4705 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -64,11 +64,13 @@ static void free_linked_list (struct commonio_db *); static void add_one_entry (struct commonio_db *, /*@owned@*/struct commonio_entry *); static bool name_is_nis (const char *name); static int write_all (const struct commonio_db *); -static struct commonio_entry *find_entry_by_name (struct commonio_db *, - const char *); -static struct commonio_entry *next_entry_by_name (struct commonio_db *, - struct commonio_entry *pos, - const char *); +static /*@dependent@*/ /*@null@*/struct commonio_entry *find_entry_by_name ( + struct commonio_db *, + const char *); +static /*@dependent@*/ /*@null@*/struct commonio_entry *next_entry_by_name ( + struct commonio_db *, + struct commonio_entry *pos, + const char *); static int lock_count = 0; static bool nscd_need_reload = false; @@ -703,6 +705,9 @@ int commonio_sort_wrt (struct commonio_db *shadow, struct commonio_db *passwd) for (spw_ptr = shadow->head; NULL != spw_ptr; spw_ptr = spw_ptr->next) { + if (NULL == spw_ptr->eptr) { + continue; + } if (strcmp (name, shadow->ops->getname (spw_ptr->eptr)) == 0) { break; @@ -738,6 +743,7 @@ int commonio_sort_wrt (struct commonio_db *shadow, struct commonio_db *passwd) * It returns 0 if all the entries could be written correctly. */ static int write_all (const struct commonio_db *db) + /*@requires notnull db->fp@*/ { const struct commonio_entry *p; void *eptr; @@ -745,6 +751,7 @@ static int write_all (const struct commonio_db *db) for (p = db->head; NULL != p; p = p->next) { if (p->changed) { eptr = p->eptr; + assert (NULL != eptr); if (db->ops->put (eptr, db->fp) != 0) { return -1; } @@ -762,6 +769,7 @@ static int write_all (const struct commonio_db *db) int commonio_close (struct commonio_db *db) + /*@requires notnull db->fp@*/ { char buf[1024]; int errors = 0; @@ -888,9 +896,10 @@ int commonio_close (struct commonio_db *db) return errors == 0; } -static struct commonio_entry *next_entry_by_name (struct commonio_db *db, - struct commonio_entry *pos, - const char *name) +static /*@dependent@*/ /*@null@*/struct commonio_entry *next_entry_by_name ( + struct commonio_db *db, + /*@null@*/struct commonio_entry *pos, + const char *name) { struct commonio_entry *p; void *ep; @@ -909,8 +918,9 @@ static struct commonio_entry *next_entry_by_name (struct commonio_db *db, return p; } -static struct commonio_entry *find_entry_by_name (struct commonio_db *db, - const char *name) +static /*@dependent@*/ /*@null@*/struct commonio_entry *find_entry_by_name ( + struct commonio_db *db, + const char *name) { return next_entry_by_name(db, db->head, name); }