From 8ff6ca1e08f80c0ad43d176ca496674c536b1e8b Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Wed, 24 Jul 2013 16:22:27 +0000 Subject: [PATCH] In uuid_ether_add(), avoid false positives due to the limited type used to hold the sum of the bytes of the MAC address. While here, rename the variable that holds the sum from 'c' to 'sum'. Pointed out by: thompsa@ --- sys/kern/kern_uuid.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_uuid.c b/sys/kern/kern_uuid.c index c647a3f5f795..a739428062ac 100644 --- a/sys/kern/kern_uuid.c +++ b/sys/kern/kern_uuid.c @@ -200,8 +200,7 @@ sys_uuidgen(struct thread *td, struct uuidgen_args *uap) int uuid_ether_add(const uint8_t *addr) { - int i; - uint8_t c; + int i, sum; /* * Validate input. No multicast addresses and no addresses that @@ -209,10 +208,10 @@ uuid_ether_add(const uint8_t *addr) */ if (addr[0] & 0x01) return (EINVAL); - c = 0; + sum = 0; for (i = 0; i < UUID_NODE_LEN; i++) - c += addr[i]; - if (c == 0) + sum += addr[i]; + if (sum == 0) return (EINVAL); mtx_lock(&uuid_mutex);