Use strftime(3) instead of formatting struct tm by hand.
Fixes a warning on newer versions of gcc.
This commit is contained in:
@@ -517,20 +517,14 @@ display_priv_long(struct sudoers_parse_tree *parse_tree, struct passwd *pw,
|
||||
if (cs->notbefore != UNSPEC) {
|
||||
char buf[sizeof("CCYYMMDDHHMMSSZ")];
|
||||
struct tm *tm = gmtime(&cs->notbefore);
|
||||
(void)snprintf(buf, sizeof(buf),
|
||||
"%04d%02d%02d%02d%02d%02dZ",
|
||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
sudo_lbuf_append(lbuf, " NotBefore: %s\n", buf);
|
||||
if (strftime(buf, sizeof(buf), "%Y%m%d%H%M%SZ", tm) != 0)
|
||||
sudo_lbuf_append(lbuf, " NotBefore: %s\n", buf);
|
||||
}
|
||||
if (cs->notafter != UNSPEC) {
|
||||
char buf[sizeof("CCYYMMDDHHMMSSZ")];
|
||||
struct tm *tm = gmtime(&cs->notafter);
|
||||
(void)snprintf(buf, sizeof(buf),
|
||||
"%04d%02d%02d%02d%02d%02dZ",
|
||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
sudo_lbuf_append(lbuf, " NotAfter: %s\n", buf);
|
||||
if (strftime(buf, sizeof(buf), "%Y%m%d%H%M%SZ", tm) != 0)
|
||||
sudo_lbuf_append(lbuf, " NotAfter: %s\n", buf);
|
||||
}
|
||||
sudo_lbuf_append(lbuf, _(" Commands:\n"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user