gtp: sanity check tunnel ID

GTPv1 allows 32-bits tunnel IDs only.
This commit is contained in:
Pablo Neira Ayuso 2014-02-10 14:56:57 +01:00
parent a7012e1376
commit c4cc08f2cd
1 changed files with 5 additions and 1 deletions

6
gtp.c
View File

@ -931,10 +931,14 @@ static int ipv4_pdp_add(struct gtp_instance *gti, struct genl_info *info)
return -EINVAL;
}
tid = nla_get_u64(info->attrs[GTPA_TID]);
/* GTPv1 allows 32-bits tunnel IDs */
if (gtp_version == GTP_V1 && tid > UINT_MAX)
return -EINVAL;
link = nla_get_u32(info->attrs[GTPA_LINK]);
sgsn_addr = nla_get_u32(info->attrs[GTPA_SGSN_ADDRESS]);
ms_addr = nla_get_u32(info->attrs[GTPA_MS_ADDRESS]);
tid = nla_get_u64(info->attrs[GTPA_TID]);
hash_ms = ipv4_hashfn(ms_addr) % gti->hash_size;