[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(usagi-users 04014) mipv6-daemon: tiny diff



Hi,

just came across the attached while reading the MIPv6-daemon code.  
Without this diff it seems that memset will stomp over the freshly 
initialized tmp->lock.  Looks like this slipped through as the lock calls 
are not checked for error returns.

-- 
/"\  Best regards,                      | mlaier@xxxxxxxxxxx
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier@EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News
diff --git a/src/bcache.c b/src/bcache.c
index f4e40c6..e80438b 100644
--- a/src/bcache.c
+++ b/src/bcache.c
@@ -138,11 +138,11 @@ struct bcentry *bcache_alloc(int type)
 	if (tmp == NULL)
 		return NULL;
 
+	memset(tmp, 0, sizeof(*tmp));
 	if (pthread_rwlock_init(&tmp->lock, NULL)) {
 		free(tmp);
 		return NULL;
 	}
-	memset(tmp, 0, sizeof(*tmp));
 	INIT_LIST_HEAD(&tmp->tqe.list);
 	return tmp;
 }

Attachment: signature.asc
Description: This is a digitally signed message part.