From 35016346471698822834471ca2ddf9019ebd25d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Mon, 3 May 2021 17:10:44 +0200 Subject: [PATCH] libselinux: Sha1Finalise(): do not discard const qualifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mark the argument `Buffer` of `Sha1Update()` const, since it is not modified. sha1.c: In function ‘Sha1Finalise’: sha1.c:208:25: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 208 | Sha1Update(Context, (uint8_t*)"\x80", 1); | ^ sha1.c:211:29: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 211 | Sha1Update(Context, (uint8_t*)"\0", 1); | ^ Signed-off-by: Christian Göttsche --- libselinux/src/sha1.c | 10 +++++----- libselinux/src/sha1.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libselinux/src/sha1.c b/libselinux/src/sha1.c index 9a8ce01dceda..664bbcf26eef 100644 --- a/libselinux/src/sha1.c +++ b/libselinux/src/sha1.c @@ -151,7 +151,7 @@ void Sha1Update ( Sha1Context* Context, - void* Buffer, + const void* Buffer, uint32_t BufferSize ) { @@ -172,7 +172,7 @@ void TransformFunction(Context->State, Context->Buffer); for (; i + 63 < BufferSize; i += 64) { - TransformFunction(Context->State, (uint8_t*)Buffer + i); + TransformFunction(Context->State, (const uint8_t*)Buffer + i); } j = 0; } @@ -181,7 +181,7 @@ void i = 0; } - memcpy(&Context->Buffer[j], &((uint8_t*)Buffer)[i], BufferSize - i); + memcpy(&Context->Buffer[j], &((const uint8_t*)Buffer)[i], BufferSize - i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -205,10 +205,10 @@ void finalcount[i] = (unsigned char)((Context->Count[(i >= 4 ? 0 : 1)] >> ((3-(i & 3)) * 8) ) & 255); // Endian independent } - Sha1Update(Context, (uint8_t*)"\x80", 1); + Sha1Update(Context, (const uint8_t*)"\x80", 1); while ((Context->Count[0] & 504) != 448) { - Sha1Update(Context, (uint8_t*)"\0", 1); + Sha1Update(Context, (const uint8_t*)"\0", 1); } Sha1Update(Context, finalcount, 8); // Should cause a Sha1TransformFunction() diff --git a/libselinux/src/sha1.h b/libselinux/src/sha1.h index eac3c195351a..f83a6e7ed7ba 100644 --- a/libselinux/src/sha1.h +++ b/libselinux/src/sha1.h @@ -64,7 +64,7 @@ void Sha1Update ( Sha1Context* Context, - void* Buffer, + const void* Buffer, uint32_t BufferSize ); -- 2.32.0.rc1