sel: time: fix null pointer dereference in set

This is a refix of commit f0d5c17e
This commit is contained in:
Pavel Kiryukhin 2020-02-10 16:40:22 +03:00 committed by Alexander Amelkin
parent 7ccea283dd
commit f80effb1fc

View File

@ -2743,6 +2743,7 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string)
struct ipmi_rs *rsp; struct ipmi_rs *rsp;
struct ipmi_rq req; struct ipmi_rq req;
struct tm tm = {0}; struct tm tm = {0};
uint8_t msg_data[4] = {0};
time_t t; time_t t;
const char *time_format = "%x %X"; /* Use locale-defined format */ const char *time_format = "%x %X"; /* Use locale-defined format */
@ -2787,8 +2788,9 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string)
* At this point `t` is UTC. Convert it to LE and send. * At this point `t` is UTC. Convert it to LE and send.
*/ */
req.msg.data = msg_data;
htoipmi32(t, req.msg.data); htoipmi32(t, req.msg.data);
req.msg.data_len = 4; req.msg.data_len = sizeof(msg_data);
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp || rsp->ccode) { if (!rsp || rsp->ccode) {