mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-11 11:07:23 +00:00
Commit adds input validation for -N(timeout) and -R(retry) parameters. It
changes types of variables 'timeout' and 'retry' to types wich should be passed to called functions.
This commit is contained in:
parent
d4c2577a16
commit
3d5e378e90
@ -367,8 +367,8 @@ ipmi_main(int argc, char ** argv,
|
|||||||
uint16_t my_long_packet_size=0;
|
uint16_t my_long_packet_size=0;
|
||||||
uint8_t my_long_packet_set=0;
|
uint8_t my_long_packet_set=0;
|
||||||
uint8_t lookupbit = 0x10; /* use name-only lookup by default */
|
uint8_t lookupbit = 0x10; /* use name-only lookup by default */
|
||||||
uint8_t retry = 0;
|
int retry = 0;
|
||||||
uint8_t timeout = 0;
|
uint32_t timeout = 0;
|
||||||
int authtype = -1;
|
int authtype = -1;
|
||||||
char * tmp = NULL;
|
char * tmp = NULL;
|
||||||
char * hostname = NULL;
|
char * hostname = NULL;
|
||||||
@ -691,10 +691,18 @@ ipmi_main(int argc, char ** argv,
|
|||||||
break;
|
break;
|
||||||
/* Retry and Timeout */
|
/* Retry and Timeout */
|
||||||
case 'R':
|
case 'R':
|
||||||
retry = (uint8_t)strtol(optarg, NULL, 0);
|
if (str2int(optarg, &retry) != 0 || retry < 0) {
|
||||||
|
lprintf(LOG_ERR, "Invalid parameter given or out of range for '-R'.");
|
||||||
|
rc = -1;
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'N':
|
case 'N':
|
||||||
timeout = (uint8_t)strtol(optarg, NULL, 0);
|
if (str2uint(optarg, &timeout) != 0) {
|
||||||
|
lprintf(LOG_ERR, "Invalid parameter given or out of range for '-N'.");
|
||||||
|
rc = -1;
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
@ -785,9 +793,9 @@ ipmi_main(int argc, char ** argv,
|
|||||||
IPMI_SESSION_PRIV_ADMIN); /* default */
|
IPMI_SESSION_PRIV_ADMIN); /* default */
|
||||||
/* Adding retry and timeout for interface that support it */
|
/* Adding retry and timeout for interface that support it */
|
||||||
if (retry > 0)
|
if (retry > 0)
|
||||||
ipmi_intf_session_set_retry(ipmi_main_intf, (uint8_t)retry);
|
ipmi_intf_session_set_retry(ipmi_main_intf, retry);
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
ipmi_intf_session_set_timeout(ipmi_main_intf, (uint8_t)timeout);
|
ipmi_intf_session_set_timeout(ipmi_main_intf, timeout);
|
||||||
|
|
||||||
ipmi_intf_session_set_lookupbit(ipmi_main_intf, lookupbit);
|
ipmi_intf_session_set_lookupbit(ipmi_main_intf, lookupbit);
|
||||||
ipmi_intf_session_set_sol_escape_char(ipmi_main_intf, sol_escape_char);
|
ipmi_intf_session_set_sol_escape_char(ipmi_main_intf, sol_escape_char);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user