Should use (sizeof(array)/sizeof(array[0]) for looping over
authoraland <aland>
Sat, 7 Apr 2007 22:32:37 +0000 (22:32 +0000)
committeraland <aland>
Sat, 7 Apr 2007 22:32:37 +0000 (22:32 +0000)
the entries

This fixes Coverity bug #12

src/modules/rlm_otp/otp_pwe.c

index f0c9b99..c3008f7 100644 (file)
@@ -45,7 +45,8 @@ RCSID("$Id$")
 #include <string.h>
 
 /* Attribute IDs for supported password encodings. */
-int pwattr[8];
+#define SIZEOF_PWATTR (4 * 2)
+int pwattr[SIZEOF_PWATTR];
 
 
 /* Initialize the pwattr array for supported password encodings. */
@@ -109,7 +110,7 @@ otp_pwe_present(const REQUEST *request)
 {
   unsigned i;
 
-  for (i = 0; i < sizeof(pwattr); i += 2) {
+  for (i = 0; i < SIZEOF_PWATTR; i += 2) {
     if (pairfind(request->packet->vps, pwattr[i]) &&
         pairfind(request->packet->vps, pwattr[i + 1])) {
       DEBUG("rlm_otp: %s: password attributes %d, %d", __func__,