diff --git a/dtls.c b/dtls.c index 8be677e..f866092 100644 --- a/dtls.c +++ b/dtls.c @@ -239,6 +239,10 @@ unsigned char *raddtlsget(SSL *ssl, struct gqueue *rbios, int timeout) { } len = RADLEN(buf); + if (len < 4) { + debug(DBG_ERR, "raddtlsget: length too small"); + continue; + } rad = malloc(len); if (!rad) { debug(DBG_ERR, "raddtlsget: malloc failed"); diff --git a/tcp.c b/tcp.c index 6de39fc..515acbf 100644 --- a/tcp.c +++ b/tcp.c @@ -173,6 +173,10 @@ unsigned char *radtcpget(int s, int timeout) { } len = RADLEN(buf); + if (len < 4) { + debug(DBG_ERR, "radtcpget: length too small"); + continue; + } rad = malloc(len); if (!rad) { debug(DBG_ERR, "radtcpget: malloc failed"); diff --git a/tls.c b/tls.c index 90c3dc9..41defea 100644 --- a/tls.c +++ b/tls.c @@ -220,6 +220,10 @@ unsigned char *radtlsget(SSL *ssl, int timeout) { } len = RADLEN(buf); + if (len < 4) { + debug(DBG_ERR, "radtlsget: length too small"); + continue; + } rad = malloc(len); if (!rad) { debug(DBG_ERR, "radtlsget: malloc failed");