summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2021-07-02 11:10:33 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2021-07-02 11:10:33 +0000
commitb3c8ddae146019e53ab8bca2eacee5d945ce7498 (patch)
tree65cb988a265f5dc6618047e4ac37895c3947b116
parent22a2cadcde6f5165c252725eb50bcf4144fbbb55 (diff)
downloadlibapr-b3c8ddae146019e53ab8bca2eacee5d945ce7498.tar.gz
Merge r1889604, r1807975 from trunk:
* random/unix/sha2.c (apr__SHA256_Final, apr__SHA256_End): Fix parameter buffer lengths to match declaration, avoiding GCC 11 warning. (no functional change) Bounds-check human-readable date fields (credit: Stefan Sperling) Submitted by: jorton, niq Reviewed by: jorton git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1891198 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--random/unix/sha2.c4
-rw-r--r--time/unix/time.c3
-rw-r--r--time/win32/time.c6
3 files changed, 11 insertions, 2 deletions
diff --git a/random/unix/sha2.c b/random/unix/sha2.c
index 12c257d1f..8059a9d78 100644
--- a/random/unix/sha2.c
+++ b/random/unix/sha2.c
@@ -425,7 +425,7 @@ void apr__SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len)
usedspace = freespace = 0;
}
-void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
+void apr__SHA256_Final(sha2_byte digest[SHA256_DIGEST_LENGTH], SHA256_CTX* context) {
sha2_word32 *d = (sha2_word32*)digest;
unsigned int usedspace;
@@ -496,7 +496,7 @@ void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
usedspace = 0;
}
-char *apr__SHA256_End(SHA256_CTX* context, char buffer[]) {
+char *apr__SHA256_End(SHA256_CTX* context, char buffer[SHA256_DIGEST_STRING_LENGTH]) {
sha2_byte digest[SHA256_DIGEST_LENGTH], *d = digest;
int i;
diff --git a/time/unix/time.c b/time/unix/time.c
index f273beb55..7389a20e9 100644
--- a/time/unix/time.c
+++ b/time/unix/time.c
@@ -142,6 +142,9 @@ APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, apr_time_exp_t *xt)
static const int dayoffset[12] =
{306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
+ if (xt->tm_mon < 0 || xt->tm_mon >= 12)
+ return APR_EBADDATE;
+
/* shift new year to 1st March in order to make leap year calc easy */
if (xt->tm_mon < 2)
diff --git a/time/win32/time.c b/time/win32/time.c
index 81dc2a478..eb1e6f14c 100644
--- a/time/win32/time.c
+++ b/time/win32/time.c
@@ -54,6 +54,9 @@ 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.
*/
@@ -228,6 +231,9 @@ APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t,
static const int dayoffset[12] =
{306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
+ if (xt->tm_mon < 0 || xt->tm_mon >= 12)
+ return APR_EBADDATE;
+
/* shift new year to 1st March in order to make leap year calc easy */
if (xt->tm_mon < 2)