Free memory if out of memory
[freeradius.git] / src / modules / rlm_eap / types / rlm_eap_md5 / eap_md5.c
index 2411d4b..f87c8de 100644 (file)
@@ -15,9 +15,9 @@
  *
  *   You should have received a copy of the GNU General Public License
  *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  *
- * Copyright 2000,2001  The FreeRADIUS server project
+ * Copyright 2000,2001,2006  The FreeRADIUS server project
  * Copyright 2001  hereUare Communications, Inc. <raghud@hereuare.com>
  */
 
@@ -35,6 +35,9 @@
  *
  */
 
+#include <freeradius-devel/ident.h>
+RCSID("$Id$")
+
 #include <stdio.h>
 #include <stdlib.h>
 #include "eap.h"
@@ -184,7 +187,7 @@ int eapmd5_verify(MD5_PACKET *packet, VALUE_PAIR* password,
         */
        *ptr++ = packet->id;
        len++;
-       memcpy(ptr, password->strvalue, password->length);
+       memcpy(ptr, password->vp_strvalue, password->length);
        ptr += password->length;
        len += password->length;
 
@@ -194,7 +197,7 @@ int eapmd5_verify(MD5_PACKET *packet, VALUE_PAIR* password,
        memcpy(ptr, challenge, MD5_CHALLENGE_LEN);
        len += MD5_CHALLENGE_LEN;
 
-       librad_md5_calc((u_char *)output, (u_char *)string, len);
+       fr_md5_calc((u_char *)output, (u_char *)string, len);
 
        /*
         *      The length of the response is always 16 for MD5.
@@ -222,10 +225,10 @@ int eapmd5_compose(EAP_DS *eap_ds, MD5_PACKET *reply)
                eap_ds->request->type.type = PW_EAP_MD5;
 
                rad_assert(reply->length > 0);
-               rad_assert(reply->value_size < 256);
 
                eap_ds->request->type.data = malloc(reply->length);
                if (eap_ds->request->type.data == NULL) {
+                       eapmd5_free(&reply);
                        radlog(L_ERR, "rlm_eap_md5: out of memory");
                        return 0;
                }