strcpy doesn't need a '-1' in the sizeof
authoraland <aland>
Mon, 12 Mar 2007 15:10:19 +0000 (15:10 +0000)
committeraland <aland>
Mon, 12 Mar 2007 15:10:19 +0000 (15:10 +0000)
src/main/xlat.c
src/modules/rlm_counter/rlm_counter.c
src/modules/rlm_ldap/rlm_ldap.c

index b299f30..25e76e9 100644 (file)
@@ -966,12 +966,12 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                p++;
                                break;
                        case 'A': /* radacct_dir */
-                               strlcpy(q,radacct_dir,freespace-1);
+                               strlcpy(q,radacct_dir,freespace);
                                q += strlen(q);
                                p++;
                                break;
                        case 'C': /* ClientName */
-                               strlcpy(q,client_name_old(&request->packet->src_ipaddr),freespace-1);
+                               strlcpy(q,client_name_old(&request->packet->src_ipaddr),freespace);
                                q += strlen(q);
                                p++;
                                break;
@@ -994,7 +994,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                p++;
                                break;
                        case 'L': /* radlog_dir */
-                               strlcpy(q,radlog_dir,freespace-1);
+                               strlcpy(q,radlog_dir,freespace);
                                q += strlen(q);
                                p++;
                                break;
@@ -1003,7 +1003,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                p++;
                                break;
                        case 'R': /* radius_dir */
-                               strlcpy(q,radius_dir,freespace-1);
+                               strlcpy(q,radius_dir,freespace);
                                q += strlen(q);
                                p++;
                                break;
@@ -1031,9 +1031,9 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                break;
                        case 'V': /* Request-Authenticator */
                                if (request->packet->verified)
-                                       strlcpy(q,"Verified",freespace-1);
+                                       strlcpy(q,"Verified",freespace);
                                else
-                                       strlcpy(q,"None",freespace-1);
+                                       strlcpy(q,"None",freespace);
                                q += strlen(q);
                                p++;
                                break;
index 68da470..2a523b6 100644 (file)
@@ -664,7 +664,8 @@ static int counter_accounting(void *instance, REQUEST *request)
                DEBUG("rlm_counter: Could not find the requested key in the database.");
                counter.user_counter = 0;
                if (uniqueid_vp != NULL)
-                       strlcpy(counter.uniqueid,uniqueid_vp->vp_strvalue,UNIQUEID_MAX_LEN - 1);
+                       strlcpy(counter.uniqueid,uniqueid_vp->vp_strvalue,
+                               sizeof(counter.uniqueid));
                else
                        memset((char *)counter.uniqueid,0,UNIQUEID_MAX_LEN);
        }
@@ -680,7 +681,8 @@ static int counter_accounting(void *instance, REQUEST *request)
                                DEBUG("rlm_counter: Unique IDs for user match. Droping the request.");
                                return RLM_MODULE_NOOP;
                        }
-                       strlcpy(counter.uniqueid,uniqueid_vp->vp_strvalue,UNIQUEID_MAX_LEN - 1);
+                       strlcpy(counter.uniqueid,uniqueid_vp->vp_strvalue,
+                               sizeof(counter.uniqueid));
                }
                DEBUG("rlm_counter: User=%s, Counter=%d.",request->username->vp_strvalue,counter.user_counter);
        }
index 53e8aa4..fcbdaf8 100644 (file)
@@ -1541,7 +1541,7 @@ static int ldap_authorize(void *instance, REQUEST * request)
                                                }
 
                                                passwd_len = strlen(passwd_val);
-                                               strlcpy(passwd_item->vp_strvalue,passwd_val,MAX_STRING_LEN - 1);
+                                               strlcpy(passwd_item->vp_strvalue,passwd_val,sizeof(passwd_item->vp_strvalue));
                                                passwd_item->length = (passwd_len > (MAX_STRING_LEN - 1)) ? (MAX_STRING_LEN - 1) : passwd_len;
                                                pairadd(&request->config_items,passwd_item);