Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/msvcrt/time.c | 10 ++++------ dlls/ucrtbase/tests/misc.c | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index 288b4d5cda..127a2164b8 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -1344,12 +1344,10 @@ static MSVCRT_size_t strftime_impl(STRFTIME_CHAR *str, MSVCRT_size_t max, return 0; break; case 'I': - tmp = mstm->tm_hour; - if(tmp > 12) - tmp -= 12; - else if(!tmp) - tmp = 12; - if(!strftime_int(str, &ret, max, tmp, alternate ? 0 : 2, 1, 12)) + if(!MSVCRT_CHECK_PMT(mstm->tm_hour>=0 && mstm->tm_hour<=23)) + goto einval_error; + if(!strftime_int(str, &ret, max, (mstm->tm_hour + 11) % 12 + 1, + alternate ? 0 : 2, 1, 12)) return 0; break; case 'j': diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c index 6700b4bdf1..c242546a80 100644 --- a/dlls/ucrtbase/tests/misc.c +++ b/dlls/ucrtbase/tests/misc.c @@ -965,14 +965,14 @@ static void test_strftime(void) {"%u", "6", { 0, 0, 0, 1, 0, 117, 6, 0, 0 }}, {"%u", "", { 0, 0, 0, 1, 0, 117, 7, 0, 0 }, TRUE}, {"%h", "Jan", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, - {"%I", "", { 0, 0, -1, 1, 0, 70, 4, 0, 0 }, FALSE, TRUE}, + {"%I", "", { 0, 0, -1, 1, 0, 70, 4, 0, 0 }}, {"%I", "12", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, {"%I", "01", { 0, 0, 1, 1, 0, 70, 4, 0, 0 }}, {"%I", "11", { 0, 0, 11, 1, 0, 70, 4, 0, 0 }}, {"%I", "12", { 0, 0, 12, 1, 0, 70, 4, 0, 0 }}, {"%I", "01", { 0, 0, 13, 1, 0, 70, 4, 0, 0 }}, {"%I", "11", { 0, 0, 23, 1, 0, 70, 4, 0, 0 }}, - {"%I", "", { 0, 0, 24, 1, 0, 70, 4, 0, 0 }, TRUE}, + {"%I", "", { 0, 0, 24, 1, 0, 70, 4, 0, 0 }}, {"%n", "\n", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, {"%r", "12:00:00 AM", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }, TRUE}, {"%r", "02:00:00 PM", { 0, 0, 14, 1, 0, 121, 6, 0, 0 }, TRUE},