From 88804bc24c58d7da866c582ce639aa77af766b5a Mon Sep 17 00:00:00 2001 From: Samuel Cabrero Date: Wed, 13 Mar 2019 10:46:36 +0100 Subject: [PATCH] s4:torture: Initialize tm struct The samba3.blackbox.shadow_copy_torture tests call to strptime passing an uninitalized tm structure as an argument, but the strptime function does not write the tm.tm_isdst field. These tm structures are passed later as the mktime argument, which produces different values depending on whether the arbitrary value of the tm.tm_isdst field is lower or equal to zero or greather than zero. Signed-off-by: Samuel Cabrero Reviewed-by: Andreas Schneider Reviewed-by: Ralph Boehme --- source4/torture/smb2/create.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c index 912efaac272..0ede6add54a 100644 --- a/source4/torture/smb2/create.c +++ b/source4/torture/smb2/create.c @@ -1759,6 +1759,11 @@ static bool test_twrp_write(struct torture_context *tctx, struct smb2_tree *tree torture_comment(tctx, "Testing timewarp (%s) (%s)\n", file, snapshot); setenv("TZ", "GMT", 1); + + /* strptime does not set tm.tm_isdst but mktime assumes DST is in + * effect if it is greather than 1. */ + ZERO_STRUCT(tm); + p = strptime(snapshot, "@GMT-%Y.%m.%d-%H.%M.%S", &tm); torture_assert_goto(tctx, p != NULL, ret, done, "strptime\n"); torture_assert_goto(tctx, *p == '\0', ret, done, "strptime\n"); @@ -1858,6 +1863,11 @@ static bool test_twrp_stream(struct torture_context *tctx, torture_assert_not_null_goto(tctx, buf, ret, done, "buf\n"); setenv("TZ", "GMT", 1); + + /* strptime does not set tm.tm_isdst but mktime assumes DST is in + * effect if it is greather than 1. */ + ZERO_STRUCT(tm); + p = strptime(snapshot, "@GMT-%Y.%m.%d-%H.%M.%S", &tm); torture_assert_goto(tctx, p != NULL, ret, done, "strptime\n"); torture_assert_goto(tctx, *p == '\0', ret, done, "strptime\n"); -- 2.34.1