1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

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 <scabrero@suse.de>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Samuel Cabrero 2019-03-13 10:46:36 +01:00 committed by Andreas Schneider
parent 4a526ec470
commit 88804bc24c

View File

@ -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");