From: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> It's unlikely any input will every be bigger than 4G, but avoid any potential truncation regardless. Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> --- libsemanage/src/modules.c | 5 +---- libsemanage/src/sha256.c | 4 ++-- libsemanage/src/sha256.h | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/libsemanage/src/modules.c b/libsemanage/src/modules.c index e6a47362..e569b98d 100644 --- a/libsemanage/src/modules.c +++ b/libsemanage/src/modules.c @@ -996,7 +996,6 @@ int semanage_module_compute_checksum(semanage_handle_t *sh, size_t *checksum_len) { semanage_module_info_t *extract_info = NULL; - Sha256Context context; SHA256_HASH sha256_hash; char *checksum_str; void *data; @@ -1018,9 +1017,7 @@ int semanage_module_compute_checksum(semanage_handle_t *sh, semanage_module_info_destroy(sh, extract_info); free(extract_info); - Sha256Initialise(&context); - Sha256Update(&context, data, data_len); - Sha256Finalise(&context, &sha256_hash); + Sha256Calculate(data, data_len, &sha256_hash); munmap(data, data_len); diff --git a/libsemanage/src/sha256.c b/libsemanage/src/sha256.c index 79664138..9daac285 100644 --- a/libsemanage/src/sha256.c +++ b/libsemanage/src/sha256.c @@ -180,7 +180,7 @@ void ( Sha256Context* Context, // [in out] void const* Buffer, // [in] - uint32_t BufferSize // [in] + size_t BufferSize // [in] ) { uint32_t n; @@ -282,7 +282,7 @@ void Sha256Calculate ( void const* Buffer, // [in] - uint32_t BufferSize, // [in] + size_t BufferSize, // [in] SHA256_HASH* Digest // [in] ) { diff --git a/libsemanage/src/sha256.h b/libsemanage/src/sha256.h index 406ed869..fbabd1f8 100644 --- a/libsemanage/src/sha256.h +++ b/libsemanage/src/sha256.h @@ -58,7 +58,7 @@ void ( Sha256Context* Context, // [in out] void const* Buffer, // [in] - uint32_t BufferSize // [in] + size_t BufferSize // [in] ); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -84,6 +84,6 @@ void Sha256Calculate ( void const* Buffer, // [in] - uint32_t BufferSize, // [in] + size_t BufferSize, // [in] SHA256_HASH* Digest // [in] ); -- 2.45.2