import from branch_1_1:
authorfcusack <fcusack>
Wed, 23 May 2007 22:08:38 +0000 (22:08 +0000)
committerfcusack <fcusack>
Wed, 23 May 2007 22:08:38 +0000 (22:08 +0000)
Should use (sizeof(array)/sizeof(array[0]) for looping over
the entries

This fixes Coverity bug #12

src/modules/rlm_otp/otp_pwe.c

index e3e56b8..abad891 100644 (file)
@@ -44,7 +44,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. */
@@ -108,7 +109,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__,