bgpd, zebra: don't compare unsigned < 0

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2020-04-04 23:26:19 -04:00
parent cd05906c41
commit 1e03d6bc76
2 changed files with 18 additions and 10 deletions

View File

@ -425,17 +425,21 @@ int main(int argc, char **argv)
else else
bgp_port = tmp_port; bgp_port = tmp_port;
break; break;
case 'e': case 'e': {
multipath_num = atoi(optarg); unsigned long int parsed_multipath =
if (multipath_num > MULTIPATH_NUM strtoul(optarg, NULL, 10);
|| multipath_num <= 0) { if (parsed_multipath == 0
|| parsed_multipath > MULTIPATH_NUM
|| parsed_multipath > UINT_MAX) {
flog_err( flog_err(
EC_BGP_MULTIPATH, EC_BGP_MULTIPATH,
"Multipath Number specified must be less than %d and greater than 0", "Multipath Number specified must be less than %u and greater than 0",
MULTIPATH_NUM); MULTIPATH_NUM);
return 1; return 1;
} }
multipath_num = parsed_multipath;
break; break;
}
case 'l': case 'l':
bgp_address = optarg; bgp_address = optarg;
/* listenon implies -n */ /* listenon implies -n */

View File

@ -331,17 +331,21 @@ int main(int argc, char **argv)
case 'a': case 'a':
allow_delete = 1; allow_delete = 1;
break; break;
case 'e': case 'e': {
zrouter.multipath_num = atoi(optarg); unsigned long int parsed_multipath =
if (zrouter.multipath_num > MULTIPATH_NUM strtoul(optarg, NULL, 10);
|| zrouter.multipath_num <= 0) { if (parsed_multipath == 0
|| parsed_multipath > MULTIPATH_NUM
|| parsed_multipath > UINT32_MAX) {
flog_err( flog_err(
EC_ZEBRA_BAD_MULTIPATH_NUM, EC_ZEBRA_BAD_MULTIPATH_NUM,
"Multipath Number specified must be less than %d and greater than 0", "Multipath Number specified must be less than %u and greater than 0",
MULTIPATH_NUM); MULTIPATH_NUM);
return 1; return 1;
} }
zrouter.multipath_num = parsed_multipath;
break; break;
}
case 'o': case 'o':
vrf_default_name_configured = optarg; vrf_default_name_configured = optarg;
break; break;