summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2018-08-31 16:42:15 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2018-08-31 16:42:15 +0000
commite5939bcedc880042da12415a57ef3406b71e43f7 (patch)
treeb76940daa1c7ae8253724fb2ab7dc0af5d073f1d
parent2ec1a99a4d32147073a310aca859f15ad386cde3 (diff)
downloadlibapr-e5939bcedc880042da12415a57ef3406b71e43f7.tar.gz
Resolve invalid rvalue from void() function, the test is only required in one
single case of user-provided input, to avoid an index into invalid memory. Backports: 1839769 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1839771 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--time/win32/time.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/time/win32/time.c b/time/win32/time.c
index 1a705443b..6f4590541 100644
--- a/time/win32/time.c
+++ b/time/win32/time.c
@@ -54,9 +54,6 @@ static void SystemTimeToAprExpTime(apr_time_exp_t *xt, SYSTEMTIME *tm)
static const int dayoffset[12] =
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
- if (tm->wMonth < 1 || tm->wMonth > 12)
- return APR_EBADDATE;
-
/* Note; the caller is responsible for filling in detailed tm_usec,
* tm_gmtoff and tm_isdst data when applicable.
*/
@@ -111,6 +108,7 @@ APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result,
FileTimeToSystemTime(&ft, &st);
/* The Platform SDK documents that SYSTEMTIME/FILETIME are
* generally UTC, so no timezone info needed
+ * The time value makes a roundtrip, st cannot be invalid below.
*/
SystemTimeToAprExpTime(result, &st);
result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC);
@@ -127,6 +125,7 @@ APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result,
FileTimeToSystemTime(&ft, &st);
/* The Platform SDK documents that SYSTEMTIME/FILETIME are
* generally UTC, so we will simply note the offs used.
+ * The time value makes a roundtrip, st cannot be invalid below.
*/
SystemTimeToAprExpTime(result, &st);
result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC);
@@ -158,6 +157,7 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result,
* because FileTimeToLocalFileFime is documented that the
* resulting time local file time would have DST relative
* to the *present* date, not the date converted.
+ * The time value makes a roundtrip, localst cannot be invalid below.
*/
SystemTimeToTzSpecificLocalTime(tz, &st, &localst);
SystemTimeToAprExpTime(result, &localst);
@@ -187,6 +187,7 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result,
TIME_ZONE_INFORMATION tz;
/* XXX: This code is simply *wrong*. The time converted will always
* map to the *now current* status of daylight savings time.
+ * The time value makes a roundtrip, st cannot be invalid below.
*/
FileTimeToLocalFileTime(&ft, &localft);
@@ -298,6 +299,9 @@ APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime,
/* The Platform SDK documents that SYSTEMTIME/FILETIME are
* generally UTC, so no timezone info needed
*/
+ if (tm->wMonth < 1 || tm->wMonth > 12)
+ return APR_EBADDATE;
+
SystemTimeToAprExpTime(aprtime, *ostime);
return APR_SUCCESS;
}