Be more clear for static analysis (LGTM) that this does not overflow. #1834

This commit is contained in:
dmiller 2019-12-29 15:52:59 +00:00
parent ee95fa8d30
commit 0403751060

View file

@ -201,7 +201,7 @@ int TargetGroup::rewind() {
* get_next_host should be used for skipping the last octet :-)
* returns: number of hosts skipped */
int TargetGroup::skip_range(_octet_nums octet) {
unsigned long hosts_skipped = 0, /* number of hosts skipped */
u32 hosts_skipped = 0, /* number of hosts skipped */
oct = 0; /* octect number */
int i = 0; /* simple lcv */
@ -212,11 +212,11 @@ int TargetGroup::skip_range(_octet_nums octet) {
switch (octet) {
case FIRST_OCTET:
oct = 0;
hosts_skipped = (last[1] + 1) * (last[2] + 1) * (last[3] + 1);
hosts_skipped = (u32)(last[1] + 1) * (last[2] + 1) * (last[3] + 1);
break;
case SECOND_OCTET:
oct = 1;
hosts_skipped = (last[2] + 1) * (last[3] + 1);
hosts_skipped = (u32)(last[2] + 1) * (last[3] + 1);
break;
case THIRD_OCTET:
oct = 2;