handle_pong(void)
{
struct ead_msg_pong *pong = EAD_DATA(msg, pong);
handle_pong(void)
{
struct ead_msg_pong *pong = EAD_DATA(msg, pong);
- int len = msg->len - sizeof(struct ead_msg_pong);
+ int len = ntohl(msg->len) - sizeof(struct ead_msg_pong);
+
+ if (len <= 0)
+ return false;
pong->name[len] = 0;
auth_type = ntohs(pong->auth_type);
pong->name[len] = 0;
auth_type = ntohs(pong->auth_type);
msg->len = htonl(sizeof(struct ead_msg_pong) + slen);
strncpy(pong->name, dev_name, slen);
msg->len = htonl(sizeof(struct ead_msg_pong) + slen);
strncpy(pong->name, dev_name, slen);
pong->auth_type = htons(EAD_AUTH_MD5);
return true;
pong->auth_type = htons(EAD_AUTH_MD5);
return true;