On 01/29/2014 01:29 PM, Jakub Hrozek wrote:
On Wed, Jan 29, 2014 at 12:58:24PM +0100, Pavel Březina wrote:
https://fedorahosted.org/sssd/ticket/2213
for (format = formats; *format != NULL; format++) {
tret = strptime(str, *format, &tm);
if (tret != NULL && *tret == '\0') {
+ /* strptime() leaves isdst uninitialized. We set it to zero to
+ * disable daylight saving time conversion. */
+ tm.tm_isdst = 0;
+
Isn't it safer to memset the tm structure to zero before calling
strptime? That way you'd be protected against any other fields being
uninitialized as well.
You are probably right. New patch is attached.
From 237fac1e02e76ccc1123846cff019e1f1a0dca72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrez...@redhat.com>
Date: Wed, 29 Jan 2014 12:56:08 +0100
Subject: [PATCH] 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 d729db18774e5d2c0f3fb355b1881eeff0f64cda..7253a3ab468f0b043ca3e38714efd13d820fb02e 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.7.11.7
_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel