]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/radius/avpair.c
pppd.8: Document netmask option
[ppp.git] / pppd / plugins / radius / avpair.c
index b97a7cf3632fbf4dcdccf51e724abe68c59ac897..bbe141d2d80acdc439307430c8916371c3e0e362 100644 (file)
@@ -31,7 +31,7 @@ static void rc_extract_vendor_specific_attributes(int attrlen,
  *
  */
 
-VALUE_PAIR *rc_avpair_add (VALUE_PAIR **list, int attrid, void *pval, int len,
+VALUE_PAIR *rc_avpair_add (VALUE_PAIR **list, int attrid, const void *pval, int len,
                           int vendorcode)
 {
        VALUE_PAIR     *vp;
@@ -57,7 +57,7 @@ VALUE_PAIR *rc_avpair_add (VALUE_PAIR **list, int attrid, void *pval, int len,
  *
  */
 
-int rc_avpair_assign (VALUE_PAIR *vp, void *pval, int len)
+int rc_avpair_assign (VALUE_PAIR *vp, const void *pval, int len)
 {
        int     result = -1;
 
@@ -65,19 +65,19 @@ int rc_avpair_assign (VALUE_PAIR *vp, void *pval, int len)
        {
                case PW_TYPE_STRING:
 
-                       if (((len == 0) && (strlen ((char *) pval)) > AUTH_STRING_LEN)
+                       if (((len == 0) && (strlen ((const char *) pval)) > AUTH_STRING_LEN)
                            || (len > AUTH_STRING_LEN)) {
                                error("rc_avpair_assign: bad attribute length");
                                return result;
                    }
 
                        if (len > 0) {
-                               memcpy(vp->strvalue, (char *)pval, len);
+                               memcpy(vp->strvalue, (const char *)pval, len);
                                vp->strvalue[len] = '\0';
                                vp->lvalue = len;
                        } else {
-                       strncpy (vp->strvalue, (char *) pval, AUTH_STRING_LEN);
-                       vp->lvalue = strlen((char *) pval);
+                       strncpy ((char*) vp->strvalue, (const char *) pval, AUTH_STRING_LEN);
+                       vp->lvalue = strlen((const char *) pval);
                        }
 
                        result = 0;
@@ -107,7 +107,7 @@ int rc_avpair_assign (VALUE_PAIR *vp, void *pval, int len)
  *
  */
 
-VALUE_PAIR *rc_avpair_new (int attrid, void *pval, int len, int vendorcode)
+VALUE_PAIR *rc_avpair_new (int attrid, const void *pval, int len, int vendorcode)
 {
        VALUE_PAIR     *vp = (VALUE_PAIR *) NULL;
        DICT_ATTR      *pda;
@@ -161,7 +161,7 @@ VALUE_PAIR *rc_avpair_gen (AUTH_HDR *auth)
        DICT_ATTR      *attr;
        VALUE_PAIR     *vp;
        VALUE_PAIR     *pair;
-       unsigned char   hex[3];         /* For hex string conversion. */
+       char            hex[3];         /* For hex string conversion. */
        char            buffer[512];
 
        /*
@@ -175,12 +175,12 @@ VALUE_PAIR *rc_avpair_gen (AUTH_HDR *auth)
        {
                attribute = *ptr++;
                attrlen = *ptr++;
-               attrlen -= 2;
-               if (attrlen < 0)
+               if (attrlen < 2 || attrlen > length)
                {
                        error("rc_avpair_gen: received attribute with invalid length");
                        break;
                }
+               attrlen -= 2;
 
                /* Handle vendor-specific specially */
                if (attribute == PW_VENDOR_SPECIFIC) {
@@ -426,7 +426,7 @@ void rc_avpair_insert (VALUE_PAIR **a, VALUE_PAIR *p, VALUE_PAIR *b)
        else /* look for the "p" entry in the "a" list (or run to end) */
        {
                this_node = *a;
-               while (this_node != (VALUE_PAIR *) NULL)
+               while (this_node->next != (VALUE_PAIR *) NULL)
                {
                        if (this_node == p)
                        {
@@ -600,7 +600,7 @@ int rc_avpair_parse (char *buffer, VALUE_PAIR **first_pair)
                        {
 
                            case PW_TYPE_STRING:
-                               strcpy (pair->strvalue, valstr);
+                               strcpy ((char*) pair->strvalue, valstr);
                                pair->lvalue = strlen(valstr);
                                break;
 
@@ -725,7 +725,7 @@ int rc_avpair_tostr (VALUE_PAIR *pair, char *name, int ln, char *value, int lv)
                        }
                        else
                        {
-                               strncat(value, ptr, 1);
+                               strncat(value, (char*) ptr, 1);
                                lv--;
                                if (lv < 0) break;
                        }