]> granicus.if.org Git - sudo/commitdiff
Cast len from size_t to uint64_t before bit shifting since we are
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 11 Nov 2016 17:59:42 +0000 (10:59 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 11 Nov 2016 17:59:42 +0000 (10:59 -0700)
adding to count which is also uint64_t.  Quiets a PVS-Studio warning.

lib/util/sha2.c

index b04abd91f9c9795821a121b523282f8e47b6c958..225a026401b4a4322e4c8f3fbb592e4bf4714797 100644 (file)
@@ -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));