Use strlcpy rather than strncpy, and use the size of the output
authoraland <aland>
Fri, 26 Jan 2007 09:39:19 +0000 (09:39 +0000)
committeraland <aland>
Fri, 26 Jan 2007 09:39:19 +0000 (09:39 +0000)
buffer rather than the size of the input buffer.

src/modules/rlm_perl/rlm_perl.c

index 92752ed..92f3a5d 100644 (file)
@@ -679,8 +679,8 @@ static int perl_xlat(void *instance, REQUEST *request, char *fmt, char * out,
                POPs ;
        } else if (count > 0) {
                tmp = POPp;
-               ret = strlen(tmp);
-               strncpy(out,tmp,ret);
+               strlcpy(out, tmp, freespace);
+               ret = strlen(out);
 
                radlog(L_DBG,"rlm_perl: Len is %d , out is %s freespace is %d",
                       ret, out,freespace);