In a struct sockaddr, sa->sa_len can be zero if uninitialized.
Make sure that this doesn't cause a problem when parsing.
This commit is contained in:
parent
1bf6f71909
commit
1baeddb81b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=64470
@ -149,7 +149,7 @@ ng_parse_generic_sockdata_getLength(const struct ng_parse_type *type,
|
||||
const struct sockaddr *sa;
|
||||
|
||||
sa = (const struct sockaddr *)(buf - SADATA_OFFSET);
|
||||
return sa->sa_len - SADATA_OFFSET;
|
||||
return (sa->sa_len < SADATA_OFFSET) ? 0 : sa->sa_len - SADATA_OFFSET;
|
||||
}
|
||||
|
||||
/* Type for the variable length data portion of a generic struct sockaddr */
|
||||
|
Loading…
Reference in New Issue
Block a user