Blob Blame History Raw
From 89eca8339610956f8d95d701dc02d3f8256e2770 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Wed, 29 Jan 2014 12:56:08 +0100
Subject: [PATCH 63/71] sudo: memset tm when converting time attributes

strptime() which is used to parse LDAP time value does not initialize
all fields of tm structure (especially tm_isdst). This results in
random behavior - when the tm is converted into timestamp via mktime(),
the result depends on current value of tm_isdst.

Resolves:
https://fedorahosted.org/sssd/ticket/2213

b
---
 src/db/sysdb_sudo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/db/sysdb_sudo.c b/src/db/sysdb_sudo.c
index 4e98b5b35f3968a1db68c32812eac71670578b60..ceaecbd2666cfb84422bd72b3109da9c4aa0f0f3 100644
--- a/src/db/sysdb_sudo.c
+++ b/src/db/sysdb_sudo.c
@@ -56,6 +56,8 @@ static errno_t sysdb_sudo_convert_time(const char *str, time_t *unix_time)
                              NULL};
 
     for (format = formats; *format != NULL; format++) {
+        /* strptime() may leave some fields uninitialized */
+        memset(&tm, 0, sizeof(struct tm));
         tret = strptime(str, *format, &tm);
         if (tret != NULL && *tret == '\0') {
             *unix_time = mktime(&tm);
-- 
1.8.4.2