From 1283382e82b11b2e9a65751e2f7a1bc011d473ff Mon Sep 17 00:00:00 2001 From: Alexander Amelkin Date: Thu, 1 Nov 2018 18:10:47 +0300 Subject: [PATCH] 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 --- lib/ipmi_main.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/ipmi_main.c b/lib/ipmi_main.c index 43ac5f7..cb7d01b 100644 --- a/lib/ipmi_main.c +++ b/lib/ipmi_main.c @@ -318,6 +318,7 @@ ipmi_main(int argc, char ** argv, uint8_t target_addr = 0; uint8_t target_channel = 0; + uint8_t u8tmp = 0; uint8_t transit_addr = 0; uint8_t transit_channel = 0; uint8_t target_lun = 0; @@ -425,17 +426,14 @@ ipmi_main(int argc, char ** argv, break; #ifdef IPMI_INTF_LANPLUS case 'C': - if (str2int(optarg, &cipher_suite_id) != 0) { - lprintf(LOG_ERR, "Invalid parameter given or out of range for '-C'."); - rc = -1; - goto out_free; - } - /* add check Cipher is -gt 0 */ - if (cipher_suite_id < 0) { - lprintf(LOG_ERR, "Cipher suite ID %i is invalid.", cipher_suite_id); + /* Cipher Suite ID is a byte as per IPMI specification */ + if (str2uchar(optarg, &u8tmp) != 0) { + lprintf(LOG_ERR, "Invalid parameter given or out of " + "range [0-255] for '-C'."); rc = -1; goto out_free; } + cipher_suite_id = u8tmp; break; #endif /* IPMI_INTF_LANPLUS */ case 'v':