replace strNcpy strlcpy -- `cat file_list`
authoraland <aland>
Tue, 13 Feb 2007 14:01:52 +0000 (14:01 +0000)
committeraland <aland>
Tue, 13 Feb 2007 14:01:52 +0000 (14:01 +0000)
29 files changed:
src/lib/dict.c
src/lib/print.c
src/lib/radius.c
src/lib/valuepair.c
src/main/auth.c
src/main/exec.c
src/main/files.c
src/main/listen.c
src/main/mainconfig.c
src/main/modules.c
src/main/radclient.c
src/main/session.c
src/main/xlat.c
src/modules/rlm_eap/radeapclient.c
src/modules/rlm_expr/paircmp.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_mschap/rlm_mschap.c
src/modules/rlm_policy/evaluate.c
src/modules/rlm_policy/parse.c
src/modules/rlm_preprocess/rlm_preprocess.c
src/modules/rlm_radutmp/rlm_radutmp.c
src/modules/rlm_radutmp/rlm_radutmp2.c
src/modules/rlm_realm/rlm_realm.c
src/modules/rlm_sql/rlm_sql.c
src/modules/rlm_sql/sql.c
src/modules/rlm_sql_log/rlm_sql_log.c
src/modules/rlm_sqlcounter/rlm_sqlcounter.c
src/modules/rlm_sqlippool/rlm_sqlippool.c
src/modules/rlm_unix/rlm_unix.c

index 34a6ea5..b1c340b 100644 (file)
@@ -624,7 +624,7 @@ int dict_addvalue(const char *namestr, const char *attrstr, int value)
                }
                memset(fixup, 0, sizeof(*fixup));
 
-               strNcpy(fixup->attrstr, attrstr, sizeof(fixup->attrstr));
+               strlcpy(fixup->attrstr, attrstr, sizeof(fixup->attrstr));
                fixup->dval = dval;
                
                /*
@@ -1500,7 +1500,7 @@ DICT_ATTR *dict_attrbyname(const char *name)
 
        if (!name) return NULL;
 
-       strNcpy(dattr.name, name, sizeof(dattr.name));
+       strlcpy(dattr.name, name, sizeof(dattr.name));
 
        return lrad_hash_table_finddata(attributes_byname, &dattr);
 }
@@ -1551,7 +1551,7 @@ DICT_VALUE *dict_valbyname(int attr, const char *name)
        dv = lrad_hash_table_finddata(values_byname, my_dv);
        if (dv) my_dv->attr = dv->value;
 
-       strNcpy(my_dv->name, name, DICT_VALUE_MAX_NAME_LEN);
+       strlcpy(my_dv->name, name, DICT_VALUE_MAX_NAME_LEN);
 
        return lrad_hash_table_finddata(values_byname, my_dv);
 }
@@ -1569,7 +1569,7 @@ int dict_vendorbyname(const char *name)
        if (!name) return 0;
 
        dv = (DICT_VENDOR *) buffer;
-       strNcpy(dv->name, name, DICT_VENDOR_MAX_NAME_LEN);
+       strlcpy(dv->name, name, DICT_VENDOR_MAX_NAME_LEN);
        
        dv = lrad_hash_table_finddata(vendors_byname, dv);
        if (!dv) return 0;
index a830070..be6e39e 100644 (file)
@@ -130,7 +130,7 @@ int vp_prints_value(char * out, int outlen, VALUE_PAIR *vp, int delimitst)
                                strcat(buf, "\"");
 
                        } else if (delimitst < 0) {
-                               strNcpy(out, vp->vp_strvalue, outlen);
+                               strlcpy(out, vp->vp_strvalue, outlen);
                                return strlen(out);
 
                        } else {
index 76b349b..1f84a10 100644 (file)
@@ -2175,7 +2175,7 @@ next_diameter:
                        dval = dict_valbyattr(vp->attribute,
                                              vp->lvalue);
                        if (dval) {
-                               strNcpy(vp->vp_strvalue,
+                               strlcpy(vp->vp_strvalue,
                                        dval->name,
                                        sizeof(vp->vp_strvalue));
                        }
@@ -2426,7 +2426,7 @@ VALUE_PAIR *rad_attr2vp(const RADIUS_PACKET *packet, const RADIUS_PACKET *origin
                        dval = dict_valbyattr(vp->attribute,
                                              vp->lvalue);
                        if (dval) {
-                               strNcpy(vp->vp_strvalue,
+                               strlcpy(vp->vp_strvalue,
                                        dval->name,
                                        sizeof(vp->vp_strvalue));
                        }
index 957d23b..3852b91 100644 (file)
@@ -619,7 +619,7 @@ static int gettime(const char *valstr, time_t *lvalue)
        memset(tm, 0, sizeof(*tm));
        tm->tm_isdst = -1;      /* don't know, and don't care about DST */
 
-       strNcpy(buf, valstr, sizeof(buf));
+       strlcpy(buf, valstr, sizeof(buf));
 
        p = buf;
        f[0] = mystrtok(&p, " \t");
@@ -751,7 +751,7 @@ VALUE_PAIR *pairparsevalue(VALUE_PAIR *vp, const char *value)
         *      Even for integers, dates and ip addresses we
         *      keep the original string in vp->vp_strvalue.
         */
-       strNcpy((char *)vp->vp_strvalue, value, sizeof(vp->vp_strvalue));
+       strlcpy((char *)vp->vp_strvalue, value, sizeof(vp->vp_strvalue));
        vp->length = strlen(vp->vp_strvalue);
 
        switch(vp->type) {
@@ -1429,7 +1429,7 @@ VALUE_PAIR *pairread(char **ptr, LRAD_TOKEN *eol)
                                return NULL;
                        }
 
-                       strNcpy(vp->vp_strvalue, value, sizeof(vp->vp_strvalue));
+                       strlcpy(vp->vp_strvalue, value, sizeof(vp->vp_strvalue));
                        vp->flags.do_xlat = 1;
                        vp->length = 0;
                } else {
@@ -1454,7 +1454,7 @@ VALUE_PAIR *pairread(char **ptr, LRAD_TOKEN *eol)
                }
 
                vp->flags.do_xlat = 1;
-               strNcpy(vp->vp_strvalue, value, sizeof(vp->vp_strvalue));
+               strlcpy(vp->vp_strvalue, value, sizeof(vp->vp_strvalue));
                vp->length = 0;
                break;
        }
index 51380b1..ffa3a6b 100644 (file)
@@ -214,7 +214,7 @@ static int rad_check_password(REQUEST *request)
                DEBUG("!!! clear text password is in Cleartext-Password, and not in User-Password. !!!");
                DEBUG("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                password_pair->attribute = PW_CLEARTEXT_PASSWORD;
-               strNcpy(password_pair->name, "Cleatext-Password",
+               strlcpy(password_pair->name, "Cleatext-Password",
                        sizeof(password_pair->name));
        }
 
index f787827..f200255 100644 (file)
@@ -95,7 +95,7 @@ int radius_exec_program(const char *cmd, REQUEST *request,
                return -1;
        }
 
-       strNcpy(mycmd, cmd, sizeof(mycmd));
+       strlcpy(mycmd, cmd, sizeof(mycmd));
 
        /*
         *      Split the string into argv's BEFORE doing radius_xlat...
@@ -444,7 +444,7 @@ int radius_exec_program(const char *cmd, REQUEST *request,
                if (n == T_OP_INVALID) {
                        DEBUG("Exec-Program-Wait: plaintext: %s", answer);
                        if (user_msg) {
-                               strNcpy(user_msg, answer, msg_len);
+                               strlcpy(user_msg, answer, msg_len);
                        }
                } else {
                        /*
index e258f80..cf4d24e 100644 (file)
@@ -161,7 +161,7 @@ parse_again:
                                 *      file.
                                 */
                                if (*s != '/') {
-                                       strNcpy(newfile, file,
+                                       strlcpy(newfile, file,
                                                sizeof(newfile));
                                        ptr = strrchr(newfile, '/');
                                        strcpy(ptr + 1, s);
index ee3807a..3806715 100644 (file)
@@ -402,7 +402,7 @@ static int common_checks(rad_listen_t *listener,
        curreq->packet = packet;
        curreq->packet->timestamp = curreq->timestamp;
        curreq->number = request_num_counter++;
-       strNcpy(curreq->secret, client->secret, sizeof(curreq->secret));
+       strlcpy(curreq->secret, client->secret, sizeof(curreq->secret));
        
        /*
         *      Remember the request in the list.
index 028abd7..35b92a8 100644 (file)
@@ -757,7 +757,7 @@ static int generate_realms(const char *filename)
                                       strlen(s), sizeof(c->secret) - 1);
                                return -1;
                        }
-                       strNcpy((char *)c->secret, s, sizeof(c->secret));
+                       strlcpy((char *)c->secret, s, sizeof(c->secret));
                }
 
                c->striprealm = 1;
index 85f528c..7324b81 100644 (file)
@@ -186,7 +186,7 @@ static module_entry_t *linkto_module(const char *module_name,
        char *p;
        const void *module;
 
-       strNcpy(myentry.name, module_name, sizeof(myentry.name));
+       strlcpy(myentry.name, module_name, sizeof(myentry.name));
        node = rbtree_finddata(module_tree, &myentry);
        if (node) return node;
 
@@ -239,7 +239,7 @@ static module_entry_t *linkto_module(const char *module_name,
        /* make room for the module type */
        node = rad_malloc(sizeof(*node));
        memset(node, 0, sizeof(*node));
-       strNcpy(node->name, module_name, sizeof(node->name));
+       strlcpy(node->name, module_name, sizeof(node->name));
        node->module = module;
        node->handle = handle;
 
@@ -333,7 +333,7 @@ module_instance_t *find_module_instance(CONF_SECTION *modules,
         *      We're done.  Fill in the rest of the data structure,
         *      and link it to the module instance list.
         */
-       strNcpy(node->name, instname, sizeof(node->name));
+       strlcpy(node->name, instname, sizeof(node->name));
 
 #ifdef HAVE_PTHREAD_H
        /*
index 8d0d585..eb9aeb4 100644 (file)
@@ -220,13 +220,13 @@ static radclient_t *radclient_init(const char *filename)
                 *      Keep a copy of the the User-Password attribute.
                 */
                if ((vp = pairfind(radclient->request->vps, PW_USER_PASSWORD)) != NULL) {
-                       strNcpy(radclient->password, vp->vp_strvalue,
+                       strlcpy(radclient->password, vp->vp_strvalue,
                                sizeof(radclient->password));
                        /*
                         *      Otherwise keep a copy of the CHAP-Password attribute.
                         */
                } else if ((vp = pairfind(radclient->request->vps, PW_CHAP_PASSWORD)) != NULL) {
-                       strNcpy(radclient->password, vp->vp_strvalue,
+                       strlcpy(radclient->password, vp->vp_strvalue,
                                sizeof(radclient->password));
                } else {
                        radclient->password[0] = '\0';
@@ -549,7 +549,7 @@ static int send_one_packet(radclient_t *radclient)
                        VALUE_PAIR *vp;
 
                        if ((vp = pairfind(radclient->request->vps, PW_USER_PASSWORD)) != NULL) {
-                               strNcpy(vp->vp_strvalue, radclient->password,
+                               strlcpy(vp->vp_strvalue, radclient->password,
                                        sizeof(vp->vp_strvalue));
                                vp->length = strlen(vp->vp_strvalue);
 
@@ -559,7 +559,7 @@ static int send_one_packet(radclient_t *radclient)
                           *           AND vp->length != 17
                           *           AND rad_chap_encode() != vp->vp_octets
                           */
-                               strNcpy(vp->vp_strvalue, radclient->password,
+                               strlcpy(vp->vp_strvalue, radclient->password,
                                        sizeof(vp->vp_strvalue));
                                vp->length = strlen(vp->vp_strvalue);
 
index 69565e8..54dee87 100644 (file)
@@ -78,7 +78,7 @@ int session_zap(REQUEST *request, uint32_t nasaddr, unsigned int port,
                pairfree(&(stopreq->packet->vps)); \
                return 0; \
        } \
-       strNcpy((char *)vp->vp_strvalue, v, sizeof vp->vp_strvalue); \
+       strlcpy((char *)vp->vp_strvalue, v, sizeof vp->vp_strvalue); \
        vp->length = strlen(v); \
        pairadd(&(stopreq->packet->vps), vp); \
        } while(0)
index f4aec03..b299f30 100644 (file)
@@ -77,22 +77,22 @@ static int valuepair2str(char * out,int outlen,VALUE_PAIR * pair,
 
        switch (type) {
        case PW_TYPE_STRING :
-               strNcpy(out,"_",outlen);
+               strlcpy(out,"_",outlen);
                break;
        case PW_TYPE_INTEGER :
-               strNcpy(out,"0",outlen);
+               strlcpy(out,"0",outlen);
                break;
        case PW_TYPE_IPADDR :
-               strNcpy(out,"?.?.?.?",outlen);
+               strlcpy(out,"?.?.?.?",outlen);
                break;
        case PW_TYPE_IPV6ADDR :
-               strNcpy(out,":?:",outlen);
+               strlcpy(out,":?:",outlen);
                break;
        case PW_TYPE_DATE :
-               strNcpy(out,"0",outlen);
+               strlcpy(out,"0",outlen);
                break;
        default :
-               strNcpy(out,"unknown_type",outlen);
+               strlcpy(out,"unknown_type",outlen);
        }
        return strlen(out);
 }
@@ -151,7 +151,7 @@ static int xlat_packet(void *instance, REQUEST *request,
                if (!p) return 0;
                if (strlen(fmt) > sizeof(buffer)) return 0;
 
-               strNcpy(buffer, fmt, p - fmt + 1);
+               strlcpy(buffer, fmt, p - fmt + 1);
 
                da = dict_attrbyname(buffer);
                if (!da) return 0;
@@ -294,9 +294,9 @@ static int xlat_packet(void *instance, REQUEST *request,
                                 */
                        case PW_REQUEST_PROCESSING_STAGE:
                                if (request->component) {
-                                       strNcpy(out, request->component, outlen);
+                                       strlcpy(out, request->component, outlen);
                                } else {
-                                       strNcpy(out, "server_core", outlen);
+                                       strlcpy(out, "server_core", outlen);
                                }
                                return strlen(out);
                        
@@ -376,7 +376,7 @@ static int xlat_regex(void *instance, REQUEST *request,
         *      Copy UP TO "freespace" bytes, including
         *      a zero byte.
         */
-       strNcpy(out, regex, outlen);
+       strlcpy(out, regex, outlen);
        return strlen(out);
 }
 #endif                         /* HAVE_REGEX_H */
@@ -419,7 +419,7 @@ static const xlat_t *xlat_find(const char *module)
                return &dict_xlat;
        }
 
-       strNcpy(my_xlat.module, module, sizeof(my_xlat.module));
+       strlcpy(my_xlat.module, module, sizeof(my_xlat.module));
        my_xlat.length = strlen(my_xlat.module);
 
        return rbtree_finddata(xlat_root, &my_xlat);
@@ -485,7 +485,7 @@ int xlat_register(const char *module, RAD_XLAT_FUNC func, void *instance)
        /*
         *      If it already exists, replace the instance.
         */
-       strNcpy(my_xlat.module, module, sizeof(my_xlat.module));
+       strlcpy(my_xlat.module, module, sizeof(my_xlat.module));
        my_xlat.length = strlen(my_xlat.module);
        c = rbtree_finddata(xlat_root, &my_xlat);
        if (c) {
@@ -506,7 +506,7 @@ int xlat_register(const char *module, RAD_XLAT_FUNC func, void *instance)
        memset(c, 0, sizeof(*c));
 
        c->do_xlat = func;
-       strNcpy(c->module, module, sizeof(c->module));
+       strlcpy(c->module, module, sizeof(c->module));
        c->length = strlen(c->module);
        c->instance = instance;
 
@@ -530,7 +530,7 @@ void xlat_unregister(const char *module, RAD_XLAT_FUNC func)
 
        if (!module) return;
 
-       strNcpy(my_xlat.module, module, sizeof(my_xlat.module));
+       strlcpy(my_xlat.module, module, sizeof(my_xlat.module));
        my_xlat.length = strlen(my_xlat.module);
 
        node = rbtree_find(xlat_root, &my_xlat);
@@ -912,7 +912,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                TM = localtime_r(&request->timestamp, &s_TM);
                                len = strftime(tmpdt, sizeof(tmpdt), "%d", TM);
                                if (len > 0) {
-                                       strNcpy(q, tmpdt, freespace);
+                                       strlcpy(q, tmpdt, freespace);
                                        q += strlen(q);
                                }
                                p++;
@@ -928,7 +928,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                        case 'l': /* request timestamp */
                                snprintf(tmpdt, sizeof(tmpdt), "%lu",
                                         (unsigned long) request->timestamp);
-                               strNcpy(q,tmpdt,freespace);
+                               strlcpy(q,tmpdt,freespace);
                                q += strlen(q);
                                p++;
                                break;
@@ -936,7 +936,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                TM = localtime_r(&request->timestamp, &s_TM);
                                len = strftime(tmpdt, sizeof(tmpdt), "%m", TM);
                                if (len > 0) {
-                                       strNcpy(q, tmpdt, freespace);
+                                       strlcpy(q, tmpdt, freespace);
                                        q += strlen(q);
                                }
                                p++;
@@ -957,7 +957,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                CTIME_R(&request->timestamp, tmpdt, sizeof(tmpdt));
                                nl = strchr(tmpdt, '\n');
                                if (nl) *nl = '\0';
-                               strNcpy(q, tmpdt, freespace);
+                               strlcpy(q, tmpdt, freespace);
                                q += strlen(q);
                                p++;
                                break;
@@ -966,12 +966,12 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                p++;
                                break;
                        case 'A': /* radacct_dir */
-                               strNcpy(q,radacct_dir,freespace-1);
+                               strlcpy(q,radacct_dir,freespace-1);
                                q += strlen(q);
                                p++;
                                break;
                        case 'C': /* ClientName */
-                               strNcpy(q,client_name_old(&request->packet->src_ipaddr),freespace-1);
+                               strlcpy(q,client_name_old(&request->packet->src_ipaddr),freespace-1);
                                q += strlen(q);
                                p++;
                                break;
@@ -979,7 +979,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                TM = localtime_r(&request->timestamp, &s_TM);
                                len = strftime(tmpdt, sizeof(tmpdt), "%Y%m%d", TM);
                                if (len > 0) {
-                                       strNcpy(q, tmpdt, freespace);
+                                       strlcpy(q, tmpdt, freespace);
                                        q += strlen(q);
                                }
                                p++;
@@ -988,13 +988,13 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                TM = localtime_r(&request->timestamp, &s_TM);
                                len = strftime(tmpdt, sizeof(tmpdt), "%H", TM);
                                if (len > 0) {
-                                       strNcpy(q, tmpdt, freespace);
+                                       strlcpy(q, tmpdt, freespace);
                                        q += strlen(q);
                                }
                                p++;
                                break;
                        case 'L': /* radlog_dir */
-                               strNcpy(q,radlog_dir,freespace-1);
+                               strlcpy(q,radlog_dir,freespace-1);
                                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 */
-                               strNcpy(q,radius_dir,freespace-1);
+                               strlcpy(q,radius_dir,freespace-1);
                                q += strlen(q);
                                p++;
                                break;
@@ -1011,7 +1011,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                TM = localtime_r(&request->timestamp, &s_TM);
                                len = strftime(tmpdt, sizeof(tmpdt), "%Y-%m-%d %H:%M:%S", TM);
                                if (len > 0) {
-                                       strNcpy(q, tmpdt, freespace);
+                                       strlcpy(q, tmpdt, freespace);
                                        q += strlen(q);
                                }
                                p++;
@@ -1020,7 +1020,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                TM = localtime_r(&request->timestamp, &s_TM);
                                len = strftime(tmpdt, sizeof(tmpdt), "%Y-%m-%d-%H.%M.%S.000000", TM);
                                if (len > 0) {
-                                       strNcpy(q, tmpdt, freespace);
+                                       strlcpy(q, tmpdt, freespace);
                                        q += strlen(q);
                                }
                                p++;
@@ -1031,9 +1031,9 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                break;
                        case 'V': /* Request-Authenticator */
                                if (request->packet->verified)
-                                       strNcpy(q,"Verified",freespace-1);
+                                       strlcpy(q,"Verified",freespace-1);
                                else
-                                       strNcpy(q,"None",freespace-1);
+                                       strlcpy(q,"None",freespace-1);
                                q += strlen(q);
                                p++;
                                break;
@@ -1041,7 +1041,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                TM = localtime_r(&request->timestamp, &s_TM);
                                len = strftime(tmpdt, sizeof(tmpdt), "%Y", TM);
                                if (len > 0) {
-                                       strNcpy(q, tmpdt, freespace);
+                                       strlcpy(q, tmpdt, freespace);
                                        q += strlen(q);
                                }
                                p++;
index d28caa2..35aca63 100644 (file)
@@ -796,15 +796,15 @@ static int sendrecv_eap(RADIUS_PACKET *rep)
         *      Keep a copy of the the User-Password attribute.
         */
        if ((vp = pairfind(rep->vps, PW_CLEARTEXT_PASSWORD)) != NULL) {
-               strNcpy(password, (char *)vp->vp_strvalue, sizeof(vp->vp_strvalue));
+               strlcpy(password, (char *)vp->vp_strvalue, sizeof(vp->vp_strvalue));
 
        } else  if ((vp = pairfind(rep->vps, PW_USER_PASSWORD)) != NULL) {
-               strNcpy(password, (char *)vp->vp_strvalue, sizeof(vp->vp_strvalue));
+               strlcpy(password, (char *)vp->vp_strvalue, sizeof(vp->vp_strvalue));
                /*
                 *      Otherwise keep a copy of the CHAP-Password attribute.
                 */
        } else if ((vp = pairfind(rep->vps, PW_CHAP_PASSWORD)) != NULL) {
-               strNcpy(password, (char *)vp->vp_strvalue, sizeof(vp->vp_strvalue));
+               strlcpy(password, (char *)vp->vp_strvalue, sizeof(vp->vp_strvalue));
        } else {
                *password = '\0';
        }
@@ -864,15 +864,15 @@ static int sendrecv_eap(RADIUS_PACKET *rep)
 
        if (*password != '\0') {
                if ((vp = pairfind(rep->vps, PW_CLEARTEXT_PASSWORD)) != NULL) {
-                       strNcpy((char *)vp->vp_strvalue, password, strlen(password) + 1);
+                       strlcpy((char *)vp->vp_strvalue, password, strlen(password) + 1);
                        vp->length = strlen(password);
 
                } else if ((vp = pairfind(rep->vps, PW_USER_PASSWORD)) != NULL) {
-                       strNcpy((char *)vp->vp_strvalue, password, strlen(password) + 1);
+                       strlcpy((char *)vp->vp_strvalue, password, strlen(password) + 1);
                        vp->length = strlen(password);
 
                } else if ((vp = pairfind(rep->vps, PW_CHAP_PASSWORD)) != NULL) {
-                       strNcpy((char *)vp->vp_strvalue, password, strlen(password) + 1);
+                       strlcpy((char *)vp->vp_strvalue, password, strlen(password) + 1);
                        vp->length = strlen(password);
 
                        rad_chap_encode(rep, (char *) vp->vp_strvalue, rep->id, vp);
index 5ec4269..4c7e1b0 100644 (file)
@@ -137,7 +137,7 @@ static int presufcmp(void *instance,
                        ret = strcmp(name + namelen - len,
                                        (char *)check->vp_strvalue);
                        if (ret == 0 && rest) {
-                               strNcpy(rest, name, namelen - len + 1);
+                               strlcpy(rest, name, namelen - len + 1);
                        }
                        break;
        }
index 083188f..98e194b 100644 (file)
@@ -1347,7 +1347,7 @@ static int ldap_authorize(void *instance, REQUEST * request)
        if (inst->default_profile || user_profile){
                char *profile = inst->default_profile;
 
-               strNcpy(filter,inst->base_filter,sizeof(filter));
+               strlcpy(filter,inst->base_filter,sizeof(filter));
                if (user_profile)
                        profile = user_profile->vp_strvalue;
                if (profile && strlen(profile)){
@@ -1388,7 +1388,7 @@ static int ldap_authorize(void *instance, REQUEST * request)
        if (inst->profile_attr){
                if ((vals = ldap_get_values(conn->ld, msg, inst->profile_attr)) != NULL) {
                        unsigned int i=0;
-                       strNcpy(filter,inst->base_filter,sizeof(filter));
+                       strlcpy(filter,inst->base_filter,sizeof(filter));
                        while(vals[i] != NULL && strlen(vals[i])){
                                if ((res = perform_search(instance, conn,
                                        vals[i], LDAP_SCOPE_BASE,
@@ -1486,7 +1486,7 @@ static int ldap_authorize(void *instance, REQUEST * request)
                                        ldap_release_conn(conn_id,inst->conns);
                                        return RLM_MODULE_FAIL;
                                }
-                               strNcpy(passwd_item->vp_strvalue, value,
+                               strlcpy(passwd_item->vp_strvalue, value,
                                        sizeof(passwd_item->vp_strvalue));
                                passwd_item->length = strlen(passwd_item->vp_strvalue);
                                pairadd(&request->config_items,passwd_item);
@@ -2531,7 +2531,7 @@ static VALUE_PAIR *ldap_pairget(LDAP *ld, LDAPMessage *entry,
                                }
                                if (do_xlat) {
                                        newpair->flags.do_xlat = 1;
-                                       strNcpy(newpair->vp_strvalue, buf,
+                                       strlcpy(newpair->vp_strvalue, buf,
                                                sizeof(newpair->vp_strvalue));
                                        newpair->length = 0;
                                }
index 3ae039f..78036d7 100644 (file)
@@ -441,7 +441,7 @@ static int mschap_xlat(void *instance, REQUEST *request,
                        p = strchr(user_name->vp_strvalue, '.');
                        if (!p) {
                                DEBUG2("  rlm_mschap: setting NT-Domain to same as machine name");
-                               strNcpy(out, user_name->vp_strvalue + 5, outlen);
+                               strlcpy(out, user_name->vp_strvalue + 5, outlen);
                        } else {
                                p++;    /* skip the period */
                                q = strchr(p, '.');
@@ -450,7 +450,7 @@ static int mschap_xlat(void *instance, REQUEST *request,
                                 * only if another period was found
                                 */
                                if (q) *q = '\0';
-                               strNcpy(out, p, outlen);
+                               strlcpy(out, p, outlen);
                                if (q) *q = '.';
                        }
                } else {
@@ -464,7 +464,7 @@ static int mschap_xlat(void *instance, REQUEST *request,
                         *      Hack.  This is simpler than the alternatives.
                         */
                        *p = '\0';
-                       strNcpy(out, user_name->vp_strvalue, outlen);
+                       strlcpy(out, user_name->vp_strvalue, outlen);
                        *p = '\\';
                }
 
@@ -512,7 +512,7 @@ static int mschap_xlat(void *instance, REQUEST *request,
                        } else {
                                p = user_name->vp_strvalue; /* use the whole User-Name */
                        }
-                       strNcpy(out, p, outlen);
+                       strlcpy(out, p, outlen);
                }
 
                return strlen(out);
index d7bb733..ca355de 100644 (file)
@@ -520,7 +520,7 @@ static int evaluate_condition(policy_state_t *state, const policy_item_t *item)
                         */
                        rcode = policy_evaluate_name(state, this->lhs);
                        data = lrad_int2str(policy_return_codes, rcode, "???");
-                       strNcpy(lhs_buffer, data, sizeof(lhs_buffer)); /* FIXME: yuck */
+                       strlcpy(lhs_buffer, data, sizeof(lhs_buffer)); /* FIXME: yuck */
                } else if (this->lhs_type == POLICY_LEX_DOUBLE_QUOTED_STRING) {
                        if (radius_xlat(lhs_buffer, sizeof(lhs_buffer), this->lhs,
                                        state->request, NULL) > 0) {
index 26f5529..2d2406a 100644 (file)
@@ -1041,10 +1041,10 @@ static int parse_module(policy_lex_file_t *lexer, policy_item_t **tail)
        /*
         *      See if we're including all of the files in a subdirectory.
         */
-       strNcpy(buffer, lexer->filename, sizeof(buffer));
+       strlcpy(buffer, lexer->filename, sizeof(buffer));
        p = strrchr(buffer, '/');
        if (p) {
-               strNcpy(p + 1, filename, sizeof(buffer) - 1 - (p - buffer));
+               strlcpy(p + 1, filename, sizeof(buffer) - 1 - (p - buffer));
        } else {
                snprintf(buffer, sizeof(buffer), "%s/%s",
                         radius_dir, filename);
@@ -1474,10 +1474,10 @@ static int parse_include(policy_lex_file_t *lexer)
        /*
         *      See if we're including all of the files in a subdirectory.
         */
-       strNcpy(buffer, lexer->filename, sizeof(buffer));
+       strlcpy(buffer, lexer->filename, sizeof(buffer));
        p = strrchr(buffer, '/');
        if (p) {
-               strNcpy(p + 1, filename, sizeof(buffer) - 1 - (p - buffer));
+               strlcpy(p + 1, filename, sizeof(buffer) - 1 - (p - buffer));
 
 #ifdef HAVE_DIRENT_H   
                p = strrchr(p + 1, '/');
@@ -1504,7 +1504,7 @@ static int parse_include(policy_lex_file_t *lexer)
                                if (dp->d_name[0] == '.') continue;
                                if (strchr(dp->d_name, '~') != NULL) continue;
 
-                               strNcpy(p, dp->d_name,
+                               strlcpy(p, dp->d_name,
                                        sizeof(buffer) - (p - buffer));
 
                                if ((stat(buffer, &buf) != 0) ||
index 02ab834..6f0aa5c 100644 (file)
@@ -166,8 +166,8 @@ static void cisco_vsa_hack(VALUE_PAIR *vp)
                         *      value field, we use only the value on
                         *      the right side of the '=' character.
                         */
-                       strNcpy(newattr, ptr + 1, sizeof(newattr));
-                       strNcpy((char *)vp->vp_strvalue, newattr,
+                       strlcpy(newattr, ptr + 1, sizeof(newattr));
+                       strlcpy((char *)vp->vp_strvalue, newattr,
                                sizeof(vp->vp_strvalue));
                        vp->length = strlen((char *)vp->vp_strvalue);
                }
@@ -225,7 +225,7 @@ static void rad_mangle(rlm_preprocess_t *data, REQUEST *request)
                 *      FIXME: should we handle this as a REALM ?
                 */
                if ((ptr = strchr(namepair->vp_strvalue, '\\')) != NULL) {
-                       strNcpy(newname, ptr + 1, sizeof(newname));
+                       strlcpy(newname, ptr + 1, sizeof(newname));
                        /* Same size */
                        strcpy(namepair->vp_strvalue, newname);
                        namepair->length = strlen(newname);
@@ -395,7 +395,7 @@ static int huntgroup_access(REQUEST *request,
                                        r = RLM_MODULE_FAIL;
                                }
 
-                               strNcpy(vp->vp_strvalue, i->name,
+                               strlcpy(vp->vp_strvalue, i->name,
                                        sizeof(vp->vp_strvalue));
                                vp->length = strlen(vp->vp_strvalue);
 
index 8fb2afe..1a00e8c 100644 (file)
@@ -317,7 +317,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
                                break;
                        case PW_CALLING_STATION_ID:
                                if(inst->callerid_ok)
-                                       strNcpy(ut.caller_id,
+                                       strlcpy(ut.caller_id,
                                                (char *)vp->vp_strvalue,
                                                sizeof(ut.caller_id));
                                break;
@@ -685,7 +685,7 @@ static int radutmp_checksimul(void *instance, REQUEST *request)
                        char session_id[sizeof(u.session_id) + 1];
                        char utmp_login[sizeof(u.login) + 1];
 
-                       strNcpy(session_id, u.session_id, sizeof(session_id));
+                       strlcpy(session_id, u.session_id, sizeof(session_id));
 
                        /*
                         *      The login name MAY fill the whole field,
@@ -703,7 +703,7 @@ static int radutmp_checksimul(void *instance, REQUEST *request)
                         *      and the NAS says "no", because "BOB"
                         *      is using the port.
                         */
-                       strNcpy(utmp_login, u.login, sizeof(u.login));
+                       strlcpy(utmp_login, u.login, sizeof(u.login));
 
                        /*
                         *      rad_check_ts may take seconds
index 607c52d..4c0a57c 100644 (file)
@@ -415,7 +415,7 @@ static int offset_walk(void *context, void *data)
 
        write(walk->fd, &utmp, sizeof(utmp));
 
-       strNcpy(myUser.login, utmp.login, sizeof(myUser.login));
+       strlcpy(myUser.login, utmp.login, sizeof(myUser.login));
        user = rbtree_finddata(walk->inst->user_tree, &myUser);
        rad_assert(user != NULL);
        rad_assert(user->simul_count > 0);
@@ -671,7 +671,7 @@ static int cache_file(rlm_radutmp_t *inst, radutmp_cache_t *cache)
                         *      Adds a trailing \0, so myUser.login has
                         *      an extra char allocated..
                         */
-                       strNcpy(myUser.login, utmp.login, sizeof(myUser.login));
+                       strlcpy(myUser.login, utmp.login, sizeof(myUser.login));
                        user = rbtree_finddata(inst->user_tree, &myUser);
                        if (user) {
                                user->simul_count++;
@@ -681,7 +681,7 @@ static int cache_file(rlm_radutmp_t *inst, radutmp_cache_t *cache)
                                 *      to the tree.
                                 */
                                user = rad_malloc(sizeof(user));
-                               strNcpy(user->login, utmp.login,
+                               strlcpy(user->login, utmp.login,
                                        sizeof(user->login));
                                user->simul_count = 1;
 
@@ -849,7 +849,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
                                break;
                        case PW_CALLING_STATION_ID:
                                if(inst->callerid_ok)
-                                       strNcpy(utmp.caller_id,
+                                       strlcpy(utmp.caller_id,
                                                (char *)vp->vp_strvalue,
                                                sizeof(utmp.caller_id));
                                break;
@@ -1008,7 +1008,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
 
                return RLM_MODULE_NOOP;
        }
-       strNcpy(utmp.login, buffer, RUT_NAMESIZE);
+       strlcpy(utmp.login, buffer, RUT_NAMESIZE);
 
        /*
         *      First, try to open the file.  If it doesn't exist,
@@ -1131,7 +1131,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
                 *      to the tree.
                 */
                user = rad_malloc(sizeof(user));
-               strNcpy(user->login, utmp.login,
+               strlcpy(user->login, utmp.login,
                        sizeof(user->login));
                user->simul_count = 1;
                
@@ -1233,7 +1233,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
                                        rbtree_deletebydata(cache->nas_ports,
                                                            nas_port);
 
-                                       strNcpy(myUser.login,
+                                       strlcpy(myUser.login,
                                                u.login, sizeof(myUser.login));
                                        user = rbtree_finddata(inst->user_tree,
                                                               &myUser);
@@ -1365,7 +1365,7 @@ static int radutmp_checksimul(void *instance, REQUEST *request)
         */
        request->simul_count = 0;
 
-       strNcpy(myUser.login, login, sizeof(myUser.login));
+       strlcpy(myUser.login, login, sizeof(myUser.login));
        pthread_mutex_lock(&inst->cache.mutex);
        user = rbtree_finddata(inst->user_tree, &myUser);
        if (user) request->simul_count = user->simul_count;
@@ -1433,7 +1433,7 @@ static int radutmp_checksimul(void *instance, REQUEST *request)
                        char session_id[sizeof(u.session_id) + 1];
                        char utmp_login[sizeof(u.login) + 1];
 
-                       strNcpy(session_id, u.session_id, sizeof(session_id));
+                       strlcpy(session_id, u.session_id, sizeof(session_id));
 
                        /*
                         *      The login name MAY fill the whole field,
@@ -1451,7 +1451,7 @@ static int radutmp_checksimul(void *instance, REQUEST *request)
                         *      and the NAS says "no", because "BOB"
                         *      is using the port.
                         */
-                       strNcpy(utmp_login, u.login, sizeof(u.login));
+                       strlcpy(utmp_login, u.login, sizeof(u.login));
 
                        /*
                         *      rad_check_ts may take seconds
index 698526b..baffe84 100644 (file)
@@ -119,7 +119,7 @@ static int check_for_realm(void *instance, REQUEST *request, REALM **returnrealm
         *      We will be modifing this later, so we want our own copy
         *      of it.
         */
-       strNcpy(namebuf, (char *)request->username->vp_strvalue, sizeof(namebuf));
+       strlcpy(namebuf, (char *)request->username->vp_strvalue, sizeof(namebuf));
        username = namebuf;
 
        switch(inst->format)
index 16ab732..00a7eb4 100644 (file)
@@ -238,7 +238,7 @@ static int generate_sql_clients(SQL_INST *inst)
              inst->config->xlat_name);
 
        /* NAS query isn't xlat'ed */
-       strNcpy(querystr, inst->config->nas_query, sizeof(querystr));
+       strlcpy(querystr, inst->config->nas_query, sizeof(querystr));
        DEBUG("rlm_sql (%s) in generate_sql_clients: query is %s",
              inst->config->xlat_name, querystr);
 
@@ -425,14 +425,14 @@ static int sql_set_user(SQL_INST *inst, REQUEST *request, char *sqlusername, con
        pairdelete(&request->packet->vps, PW_SQL_USER_NAME);
 
        if (username != NULL) {
-               strNcpy(tmpuser, username, MAX_STRING_LEN);
+               strlcpy(tmpuser, username, MAX_STRING_LEN);
        } else if (strlen(inst->config->query_user)) {
                radius_xlat(tmpuser, sizeof(tmpuser), inst->config->query_user, request, NULL);
        } else {
                return 0;
        }
 
-       strNcpy(sqlusername, tmpuser, MAX_STRING_LEN);
+       strlcpy(sqlusername, tmpuser, MAX_STRING_LEN);
        DEBUG2("rlm_sql (%s): sql_set_user escaped user --> '%s'",
                       inst->config->xlat_name, sqlusername);
        vp = pairmake("SQL-User-Name", sqlusername, 0);
@@ -504,7 +504,7 @@ static int sql_get_grouplist (SQL_INST *inst, SQLSOCK *sqlsocket, REQUEST *reque
                        group_list_tmp = group_list_tmp->next;
                }
                group_list_tmp->next = NULL;
-               strNcpy(group_list_tmp->groupname, row[0], MAX_STRING_LEN);
+               strlcpy(group_list_tmp->groupname, row[0], MAX_STRING_LEN);
        }
 
        (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
index eef248e..b79700b 100644 (file)
@@ -408,7 +408,7 @@ int sql_userparse(VALUE_PAIR ** first_pair, SQL_ROW row)
        }
        if (do_xlat) {
                pair->flags.do_xlat = 1;
-               strNcpy(pair->vp_strvalue, buf, sizeof(pair->vp_strvalue));
+               strlcpy(pair->vp_strvalue, buf, sizeof(pair->vp_strvalue));
                pair->length = 0;
        }
 
index 42d4a90..d9c5047 100644 (file)
@@ -231,7 +231,7 @@ static int sql_set_user(rlm_sql_log_t *inst, REQUEST *request, char *sqlusername
        pairdelete(&request->packet->vps, PW_SQL_USER_NAME);
 
        if (username != NULL) {
-               strNcpy(tmpuser, username, MAX_STRING_LEN);
+               strlcpy(tmpuser, username, MAX_STRING_LEN);
        } else if (inst->sql_user_name[0] != '\0') {
                radius_xlat(tmpuser, sizeof(tmpuser), inst->sql_user_name,
                            request, NULL);
@@ -240,7 +240,7 @@ static int sql_set_user(rlm_sql_log_t *inst, REQUEST *request, char *sqlusername
        }
 
        if (tmpuser[0] != '\0') {
-               strNcpy(sqlusername, tmpuser, sizeof(tmpuser));
+               strlcpy(sqlusername, tmpuser, sizeof(tmpuser));
                DEBUG2("rlm_sql_log (%s): sql_set_user escaped user --> '%s'",
                       inst->name, sqlusername);
                vp = pairmake("SQL-User-Name", sqlusername, 0);
index 31c5a1d..46f4a89 100644 (file)
@@ -354,20 +354,20 @@ static int sqlcounter_expand(char *out, int outlen, const char *fmt, void *insta
                                *q++ = *p;
                        case 'b': /* last_reset */
                                snprintf(tmpdt, sizeof(tmpdt), "%lu", data->last_reset);
-                               strNcpy(q, tmpdt, freespace);
+                               strlcpy(q, tmpdt, freespace);
                                q += strlen(q);
                                break;
                        case 'e': /* reset_time */
                                snprintf(tmpdt, sizeof(tmpdt), "%lu", data->reset_time);
-                               strNcpy(q, tmpdt, freespace);
+                               strlcpy(q, tmpdt, freespace);
                                q += strlen(q);
                                break;
                        case 'k': /* Key Name */
-                               strNcpy(q, data->key_name, freespace);
+                               strlcpy(q, data->key_name, freespace);
                                q += strlen(q);
                                break;
                        case 'S': /* SQL module instance */
-                               strNcpy(q, data->sqlmod_inst, freespace);
+                               strlcpy(q, data->sqlmod_inst, freespace);
                                q += strlen(q);
                                break;
                        default:
index c85777d..1f15c53 100644 (file)
@@ -235,13 +235,13 @@ static int sqlippool_expand(char * out, int outlen, const char * fmt, void * ins
                                *q++ = *p;
                                break;
                        case 'P': /* pool name */
-                               strNcpy(q, data->pool_name, freespace); 
+                               strlcpy(q, data->pool_name, freespace); 
                                q += strlen(q);
                                break;
                        case 'I': /* IP address */
                                if (param && param_len > 0) {
                                        if (param_len > freespace) {
-                                               strNcpy(q, param, freespace);
+                                               strlcpy(q, param, freespace);
                                                q += strlen(q);
                                        }
                                        else {
@@ -252,7 +252,7 @@ static int sqlippool_expand(char * out, int outlen, const char * fmt, void * ins
                                break;
                        case 'J': /* lease duration */
                                sprintf(tmp, "%d", data->lease_duration);
-                               strNcpy(q, tmp, freespace); 
+                               strlcpy(q, tmp, freespace); 
                                q += strlen(q);
                                break;
                        default:
index 1e5cf4d..9f70cae 100644 (file)
@@ -480,7 +480,7 @@ static int unix_accounting(void *instance, REQUEST *request)
                                if (vp->length >= sizeof(ut.ut_name)) {
                                        memcpy(ut.ut_name, (char *)vp->vp_strvalue, sizeof(ut.ut_name));
                                } else {
-                                       strNcpy(ut.ut_name, (char *)vp->vp_strvalue, sizeof(ut.ut_name));
+                                       strlcpy(ut.ut_name, (char *)vp->vp_strvalue, sizeof(ut.ut_name));
                                }
                                break;
                        case PW_LOGIN_IP_HOST:
@@ -539,7 +539,7 @@ static int unix_accounting(void *instance, REQUEST *request)
         *      and address so that the tty field is unique.
         */
        sprintf(buf, "%03d:%s", nas_port, s);
-       strNcpy(ut.ut_line, buf, sizeof(ut.ut_line));
+       strlcpy(ut.ut_line, buf, sizeof(ut.ut_line));
 
        /*
         *      We store the dynamic IP address in the hostname field.