Rewrite code with the notion that Kg is binary data, not string

- use uint8_t as the storage type
  - allocate kgkey on stack
  - do not treat incoming kgkey as 0-trminated string in
    ipmi_intf_session_set_kgkey()
This commit is contained in:
Dmitry Rakhchev
2016-07-01 11:19:30 +03:00
committed by Zdenek Styblik
parent f9211f8ed9
commit 7f8d37493f
3 changed files with 24 additions and 85 deletions

View File

@@ -264,15 +264,9 @@ ipmi_intf_session_set_sol_escape_char(struct ipmi_intf * intf, char sol_escape_c
}
void
ipmi_intf_session_set_kgkey(struct ipmi_intf * intf, char * kgkey)
ipmi_intf_session_set_kgkey(struct ipmi_intf *intf, const uint8_t *kgkey)
{
memset(intf->ssn_params.kg, 0, IPMI_KG_BUFFER_SIZE);
if (kgkey == NULL)
return;
memcpy(intf->ssn_params.kg, kgkey,
__min(strlen(kgkey), IPMI_KG_BUFFER_SIZE));
memcpy(intf->ssn_params.kg, kgkey, IPMI_KG_BUFFER_SIZE);
}
void