HEADS UP: move dictionary file to $prefix/etc/raddb/dictionary
[mech_eap.orig] / util_radius.cpp
index 04af98d..c367cb6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, JANET(UK)
+ * Copyright (c) 2011, JANET(UK)
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -448,7 +448,7 @@ gss_eap_radius_attr_provider::init(void)
 {
     gss_eap_attr_ctx::registerProvider(ATTR_TYPE_RADIUS,
                                        "urn:ietf:params:gss-eap:radius-avp",
-                                       gss_eap_radius_attr_provider::createAttrContext);
+                                       createAttrContext);
     return true;
 }
 
@@ -479,8 +479,12 @@ gssEapRadiusAddAvp(OM_uint32 *minor,
         VALUE_PAIR *vp;
         size_t n = remain;
 
-        if (n > MAX_STRING_LEN)
-            n = MAX_STRING_LEN;
+       /*
+         * There's an extra byte of padding; RADIUS AVPs can only
+         * be 253 octets.
+         */
+        if (n >= MAX_STRING_LEN)
+            n = MAX_STRING_LEN - 1;
 
         vp = paircreate(attrid, PW_TYPE_OCTETS);
         if (vp == NULL) {
@@ -681,13 +685,8 @@ avpImport(VALUE_PAIR **pVp,
         remain -= 5;
         break;
     case PW_TYPE_STRING:
-        /* check enough room to NUL terminate */
-        if (p[0] == MAX_STRING_LEN)
-            goto fail;
-        else
-        /* fallthrough */
     default:
-        if (p[0] > MAX_STRING_LEN)
+        if (p[0] >= MAX_STRING_LEN)
             goto fail;
 
         vp->length = (uint32_t)p[0];
@@ -792,7 +791,7 @@ gssEapRadiusMapError(OM_uint32 *minor,
 
     *minor = ERROR_TABLE_BASE_rse + code;
 
-    gssEapSaveStatusInfo(*minor, "%s", rs_err_msg(err, 0));
+    gssEapSaveStatusInfo(*minor, "%s", rs_err_msg(err));
     rs_err_free(err);
 
     return GSS_S_FAILURE;