lanplus: Fix -C option processing

Cipher suite ID is a byte as per IPMI spec.
Use the appropriate function and consider target endianness
(so write to a temporary variable).

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
Alexander Amelkin 2018-11-01 18:10:47 +03:00 committed by Alexander Amelkin
parent 7772254b62
commit 1283382e82

View File

@ -318,6 +318,7 @@ ipmi_main(int argc, char ** argv,
uint8_t target_addr = 0; uint8_t target_addr = 0;
uint8_t target_channel = 0; uint8_t target_channel = 0;
uint8_t u8tmp = 0;
uint8_t transit_addr = 0; uint8_t transit_addr = 0;
uint8_t transit_channel = 0; uint8_t transit_channel = 0;
uint8_t target_lun = 0; uint8_t target_lun = 0;
@ -425,17 +426,14 @@ ipmi_main(int argc, char ** argv,
break; break;
#ifdef IPMI_INTF_LANPLUS #ifdef IPMI_INTF_LANPLUS
case 'C': case 'C':
if (str2int(optarg, &cipher_suite_id) != 0) { /* Cipher Suite ID is a byte as per IPMI specification */
lprintf(LOG_ERR, "Invalid parameter given or out of range for '-C'."); if (str2uchar(optarg, &u8tmp) != 0) {
rc = -1; lprintf(LOG_ERR, "Invalid parameter given or out of "
goto out_free; "range [0-255] for '-C'.");
}
/* add check Cipher is -gt 0 */
if (cipher_suite_id < 0) {
lprintf(LOG_ERR, "Cipher suite ID %i is invalid.", cipher_suite_id);
rc = -1; rc = -1;
goto out_free; goto out_free;
} }
cipher_suite_id = u8tmp;
break; break;
#endif /* IPMI_INTF_LANPLUS */ #endif /* IPMI_INTF_LANPLUS */
case 'v': case 'v':