ipmi_sel_set_time: fix strptime() return check

The current behavior:
- correct date format is not accepted by "sel time set".
- incorrect date format that looks correct is accepted, but time is not
  set correctly.
- commands like
    ipmitool sel time set "11/22/2013 trash"
  are accepted.
This commit is contained in:
Pavel Kiryukhin 2020-02-17 12:24:48 +03:00 committed by Alexander Amelkin
parent 2a17967159
commit 284adfe2e2

View File

@ -2762,7 +2762,7 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string)
else { else {
bool error = true; /* Assume the string is invalid */ bool error = true; /* Assume the string is invalid */
/* Now let's extract time_t from the supplied string */ /* Now let's extract time_t from the supplied string */
if (!strptime(time_string, time_format, &tm)) { if (strptime(time_string, time_format, &tm) != NULL) {
tm.tm_isdst = (-1); /* look up DST information */ tm.tm_isdst = (-1); /* look up DST information */
t = mktime(&tm); t = mktime(&tm);
if (t >= 0) { if (t >= 0) {