Use strftime(3) instead of formatting struct tm by hand.

Fixes a warning on newer versions of gcc.
This commit is contained in:
Todd C. Miller
2019-07-19 20:14:44 -06:00
parent 6f3d826f8b
commit 5e424640b9
4 changed files with 18 additions and 28 deletions

18
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for sudo 1.8.28. # Generated by GNU Autoconf 2.69 for sudo 1.8.28b1.
# #
# Report bugs to <https://bugzilla.sudo.ws/>. # Report bugs to <https://bugzilla.sudo.ws/>.
# #
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='sudo' PACKAGE_NAME='sudo'
PACKAGE_TARNAME='sudo' PACKAGE_TARNAME='sudo'
PACKAGE_VERSION='1.8.28' PACKAGE_VERSION='1.8.28b1'
PACKAGE_STRING='sudo 1.8.28' PACKAGE_STRING='sudo 1.8.28b1'
PACKAGE_BUGREPORT='https://bugzilla.sudo.ws/' PACKAGE_BUGREPORT='https://bugzilla.sudo.ws/'
PACKAGE_URL='' PACKAGE_URL=''
@@ -1543,7 +1543,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures sudo 1.8.28 to adapt to many kinds of systems. \`configure' configures sudo 1.8.28b1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1608,7 +1608,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of sudo 1.8.28:";; short | recursive ) echo "Configuration of sudo 1.8.28b1:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@@ -1874,7 +1874,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
sudo configure 1.8.28 sudo configure 1.8.28b1
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2583,7 +2583,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by sudo $as_me 1.8.28, which was It was created by sudo $as_me 1.8.28b1, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@@ -27506,7 +27506,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by sudo $as_me 1.8.28, which was This file was extended by sudo $as_me 1.8.28b1, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@@ -27572,7 +27572,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
sudo config.status 1.8.28 sudo config.status 1.8.28b1
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@@ -18,7 +18,7 @@ dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
dnl dnl
AC_PREREQ([2.59]) AC_PREREQ([2.59])
AC_INIT([sudo], [1.8.28], [https://bugzilla.sudo.ws/], [sudo]) AC_INIT([sudo], [1.8.28b1], [https://bugzilla.sudo.ws/], [sudo])
AC_CONFIG_HEADER([config.h pathnames.h]) AC_CONFIG_HEADER([config.h pathnames.h])
AC_CONFIG_SRCDIR([src/sudo.c]) AC_CONFIG_SRCDIR([src/sudo.c])
dnl dnl

View File

@@ -237,18 +237,14 @@ sudoers_format_cmndspec(struct sudo_lbuf *lbuf,
if (cs->notbefore != UNSPEC && FIELD_CHANGED(prev_cs, cs, notbefore)) { if (cs->notbefore != UNSPEC && FIELD_CHANGED(prev_cs, cs, notbefore)) {
char buf[sizeof("CCYYMMDDHHMMSSZ")]; char buf[sizeof("CCYYMMDDHHMMSSZ")];
struct tm *tm = gmtime(&cs->notbefore); struct tm *tm = gmtime(&cs->notbefore);
(void)snprintf(buf, sizeof(buf), "%04d%02d%02d%02d%02d%02dZ", if (strftime(buf, sizeof(buf), "%Y%m%d%H%M%SZ", tm) != 0)
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, sudo_lbuf_append(lbuf, "NOTBEFORE=%s ", buf);
tm->tm_hour, tm->tm_min, tm->tm_sec);
sudo_lbuf_append(lbuf, "NOTBEFORE=%s ", buf);
} }
if (cs->notafter != UNSPEC && FIELD_CHANGED(prev_cs, cs, notafter)) { if (cs->notafter != UNSPEC && FIELD_CHANGED(prev_cs, cs, notafter)) {
char buf[sizeof("CCYYMMDDHHMMSSZ")]; char buf[sizeof("CCYYMMDDHHMMSSZ")];
struct tm *tm = gmtime(&cs->notafter); struct tm *tm = gmtime(&cs->notafter);
(void)snprintf(buf, sizeof(buf), "%04d%02d%02d%02d%02d%02dZ", if (strftime(buf, sizeof(buf), "%Y%m%d%H%M%SZ", tm) != 0)
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, sudo_lbuf_append(lbuf, "NOTAFTER=%s ", buf);
tm->tm_hour, tm->tm_min, tm->tm_sec);
sudo_lbuf_append(lbuf, "NOTAFTER=%s ", buf);
} }
if (TAG_CHANGED(prev_cs, cs, tags, setenv)) if (TAG_CHANGED(prev_cs, cs, tags, setenv))
sudo_lbuf_append(lbuf, tags.setenv ? "SETENV: " : "NOSETENV: "); sudo_lbuf_append(lbuf, tags.setenv ? "SETENV: " : "NOSETENV: ");

View File

@@ -517,20 +517,14 @@ display_priv_long(struct sudoers_parse_tree *parse_tree, struct passwd *pw,
if (cs->notbefore != UNSPEC) { if (cs->notbefore != UNSPEC) {
char buf[sizeof("CCYYMMDDHHMMSSZ")]; char buf[sizeof("CCYYMMDDHHMMSSZ")];
struct tm *tm = gmtime(&cs->notbefore); struct tm *tm = gmtime(&cs->notbefore);
(void)snprintf(buf, sizeof(buf), if (strftime(buf, sizeof(buf), "%Y%m%d%H%M%SZ", tm) != 0)
"%04d%02d%02d%02d%02d%02dZ", sudo_lbuf_append(lbuf, " NotBefore: %s\n", buf);
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 (cs->notafter != UNSPEC) { if (cs->notafter != UNSPEC) {
char buf[sizeof("CCYYMMDDHHMMSSZ")]; char buf[sizeof("CCYYMMDDHHMMSSZ")];
struct tm *tm = gmtime(&cs->notafter); struct tm *tm = gmtime(&cs->notafter);
(void)snprintf(buf, sizeof(buf), if (strftime(buf, sizeof(buf), "%Y%m%d%H%M%SZ", tm) != 0)
"%04d%02d%02d%02d%02d%02dZ", sudo_lbuf_append(lbuf, " NotAfter: %s\n", buf);
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);
} }
sudo_lbuf_append(lbuf, _(" Commands:\n")); sudo_lbuf_append(lbuf, _(" Commands:\n"));
} }