removed malloc() from ms chap

This commit is contained in:
Sylvain Rochet 2012-06-07 23:02:08 +02:00
parent e5355cc45f
commit 302184938a

View File

@ -377,14 +377,10 @@ static void
chapms_handle_failure(unsigned char *inp, int len) chapms_handle_failure(unsigned char *inp, int len)
{ {
int err; int err;
char *p, *msg; char *p, msg[64];
/* We want a null-terminated string for strxxx(). */ /* We want a null-terminated string for strxxx(). */
msg = malloc(len + 1); len = LWIP_MIN(len, 63);
if (!msg) {
notice("Out of memory in chapms_handle_failure");
return;
}
MEMCPY(msg, inp, len); MEMCPY(msg, inp, len);
msg[len] = 0; msg[len] = 0;
p = msg; p = msg;
@ -432,7 +428,6 @@ chapms_handle_failure(unsigned char *inp, int len)
break; break;
default: default:
free(msg);
error("Unknown MS-CHAP authentication failure: %.*v", error("Unknown MS-CHAP authentication failure: %.*v",
len, inp); len, inp);
return; return;
@ -441,7 +436,6 @@ chapms_handle_failure(unsigned char *inp, int len)
print_msg: print_msg:
if (p != NULL) if (p != NULL)
error("MS-CHAP authentication failed: %v", p); error("MS-CHAP authentication failed: %v", p);
free(msg);
} }
static void static void