From aaab5410a1b76de6f8aeb1e2fa4d8ca27e717c61 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 15 Feb 2017 14:17:09 +0100 Subject: [PATCH] webservices: Fix use of month as array index. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/webservices/tests/writer.c | 4 ++++ dlls/webservices/writer.c | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dlls/webservices/tests/writer.c b/dlls/webservices/tests/writer.c index 039de556af2..be6504ddc88 100644 --- a/dlls/webservices/tests/writer.c +++ b/dlls/webservices/tests/writer.c @@ -2716,6 +2716,10 @@ static void test_datetime(void) { 0x701ce51ced5d800, WS_DATETIME_FORMAT_LOCAL, S_OK, "1601-01-01T07:00:00+00:00", "1601-01-01T01:00:00-06:00" /* win7 */ }, { 0, WS_DATETIME_FORMAT_NONE + 1, WS_E_INVALID_FORMAT }, + { 0x38a080649c000, WS_DATETIME_FORMAT_UTC, S_OK, "0004-02-28T00:00:00Z" }, + { 0x38ad130b38000, WS_DATETIME_FORMAT_UTC, S_OK, "0004-02-29T00:00:00Z" }, + { 0x8c1505f0e438000, WS_DATETIME_FORMAT_UTC, S_OK, "2000-02-29T00:00:00Z" }, + { 0x8d46035e7870000, WS_DATETIME_FORMAT_UTC, S_OK, "2017-03-01T00:00:00Z" }, }; HRESULT hr; WS_XML_WRITER *writer; diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c index f01a5a09292..4415a2465c0 100644 --- a/dlls/webservices/writer.c +++ b/dlls/webservices/writer.c @@ -1203,7 +1203,7 @@ static inline int year_size( int year ) static ULONG format_datetime( const WS_DATETIME *ptr, unsigned char *buf ) { static const char fmt[] = "%04u-%02u-%02uT%02u:%02u:%02u"; - int day, hour, min, sec, sec_frac, month = 1, year = 1, tz_hour; + int day, hour, min, sec, sec_frac, month = 0, year = 1, tz_hour; unsigned __int64 ticks, day_ticks; ULONG len; @@ -1235,9 +1235,8 @@ static ULONG format_datetime( const WS_DATETIME *ptr, unsigned char *buf ) day -= month_days[leap_year( year )][month]; month++; } - day++; - len = sprintf( (char *)buf, fmt, year, month, day, hour, min, sec ); + len = sprintf( (char *)buf, fmt, year, month + 1, day + 1, hour, min, sec ); if (sec_frac) { static const char fmt_frac[] = ".%07u"; -- 2.11.4.GIT