From: Todd C. Miller Date: Fri, 11 Nov 2016 17:59:42 +0000 (-0700) Subject: Cast len from size_t to uint64_t before bit shifting since we are X-Git-Tag: SUDO_1_8_19^2~49 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b5e3a7aef2b38d09069a7ac0f7887f295d28a2a8;p=sudo Cast len from size_t to uint64_t before bit shifting since we are adding to count which is also uint64_t. Quiets a PVS-Studio warning. --- diff --git a/lib/util/sha2.c b/lib/util/sha2.c index b04abd91f..225a02640 100644 --- a/lib/util/sha2.c +++ b/lib/util/sha2.c @@ -255,7 +255,7 @@ SHA256Update(SHA2_CTX *ctx, const uint8_t *data, size_t len) size_t i = 0, j; j = (size_t)((ctx->count[0] >> 3) & (SHA256_BLOCK_LENGTH - 1)); - ctx->count[0] += (len << 3); + ctx->count[0] += ((uint64_t)len << 3); if ((j + len) > SHA256_BLOCK_LENGTH - 1) { memcpy(&ctx->buffer[j], data, (i = SHA256_BLOCK_LENGTH - j)); SHA256Transform(ctx->state.st32, ctx->buffer); @@ -466,8 +466,8 @@ SHA512Update(SHA2_CTX *ctx, const uint8_t *data, size_t len) size_t i = 0, j; j = (size_t)((ctx->count[0] >> 3) & (SHA512_BLOCK_LENGTH - 1)); - ctx->count[0] += (len << 3); - if (ctx->count[0] < (len << 3)) + ctx->count[0] += ((uint64_t)len << 3); + if (ctx->count[0] < ((uint64_t)len << 3)) ctx->count[1]++; if ((j + len) > SHA512_BLOCK_LENGTH - 1) { memcpy(&ctx->buffer[j], data, (i = SHA512_BLOCK_LENGTH - j));