From 7c0a0c903b407aa4140d5bdb4954fe623b7bc9ac Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 24 Feb 2026 09:02:39 +0100 Subject: [PATCH] [winpr,crypto] use size_t as length for md[45] --- winpr/libwinpr/crypto/md4.c | 14 +++++++------- winpr/libwinpr/crypto/md4.h | 2 +- winpr/libwinpr/crypto/md5.c | 14 +++++++------- winpr/libwinpr/crypto/md5.h | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/winpr/libwinpr/crypto/md4.c b/winpr/libwinpr/crypto/md4.c index 78ceb8cbe..17b970b74 100644 --- a/winpr/libwinpr/crypto/md4.c +++ b/winpr/libwinpr/crypto/md4.c @@ -96,7 +96,7 @@ static inline winpr_MD4_u32plus H(winpr_MD4_u32plus x, winpr_MD4_u32plus y, winp * This processes one or more 64-byte data blocks, but does NOT update the bit * counters. There are no alignment requirements. */ -static const void* body(WINPR_MD4_CTX* ctx, const void* data, unsigned long size) +static const void* body(WINPR_MD4_CTX* ctx, const void* data, size_t size) { const winpr_MD4_u32plus ac1 = 0x5a827999; const winpr_MD4_u32plus ac2 = 0x6ed9eba1; @@ -196,18 +196,18 @@ void winpr_MD4_Init(WINPR_MD4_CTX* ctx) ctx->hi = 0; } -void winpr_MD4_Update(WINPR_MD4_CTX* ctx, const void* data, unsigned long size) +void winpr_MD4_Update(WINPR_MD4_CTX* ctx, const void* data, size_t size) { winpr_MD4_u32plus saved_lo = ctx->lo; if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) ctx->hi++; ctx->hi += size >> 29; - unsigned long used = saved_lo & 0x3f; + size_t used = saved_lo & 0x3f; if (used) { - unsigned long available = 64 - used; + size_t available = 64 - used; if (size < available) { @@ -223,7 +223,7 @@ void winpr_MD4_Update(WINPR_MD4_CTX* ctx, const void* data, unsigned long size) if (size >= 64) { - data = body(ctx, data, size & ~(unsigned long)0x3f); + data = body(ctx, data, size & ~(size_t)0x3f); size &= 0x3f; } @@ -240,11 +240,11 @@ static inline void mdOUT(unsigned char* dst, winpr_MD4_u32plus src) void winpr_MD4_Final(unsigned char* result, WINPR_MD4_CTX* ctx) { - unsigned long used = ctx->lo & 0x3f; + size_t used = ctx->lo & 0x3f; ctx->buffer[used++] = 0x80; - unsigned long available = 64 - used; + size_t available = 64 - used; if (available < 8) { diff --git a/winpr/libwinpr/crypto/md4.h b/winpr/libwinpr/crypto/md4.h index 1ea008ecc..87c7760b0 100644 --- a/winpr/libwinpr/crypto/md4.h +++ b/winpr/libwinpr/crypto/md4.h @@ -40,7 +40,7 @@ typedef struct } WINPR_MD4_CTX; extern void winpr_MD4_Init(WINPR_MD4_CTX* ctx); -extern void winpr_MD4_Update(WINPR_MD4_CTX* ctx, const void* data, unsigned long size); +extern void winpr_MD4_Update(WINPR_MD4_CTX* ctx, const void* data, size_t size); extern void winpr_MD4_Final(unsigned char* result, WINPR_MD4_CTX* ctx); #endif diff --git a/winpr/libwinpr/crypto/md5.c b/winpr/libwinpr/crypto/md5.c index c832e7005..6613e9b6d 100644 --- a/winpr/libwinpr/crypto/md5.c +++ b/winpr/libwinpr/crypto/md5.c @@ -106,7 +106,7 @@ static inline winpr_MD5_u32plus I(winpr_MD5_u32plus x, winpr_MD5_u32plus y, winp * This processes one or more 64-byte data blocks, but does NOT update the bit * counters. There are no alignment requirements. */ -static const void* body(WINPR_MD5_CTX* ctx, const void* data, unsigned long size) +static const void* body(WINPR_MD5_CTX* ctx, const void* data, size_t size) { const unsigned char* ptr = (const unsigned char*)data; @@ -221,18 +221,18 @@ void winpr_MD5_Init(WINPR_MD5_CTX* ctx) ctx->hi = 0; } -void winpr_MD5_Update(WINPR_MD5_CTX* ctx, const void* data, unsigned long size) +void winpr_MD5_Update(WINPR_MD5_CTX* ctx, const void* data, size_t size) { winpr_MD5_u32plus saved_lo = ctx->lo; if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) ctx->hi++; ctx->hi += size >> 29; - unsigned long used = saved_lo & 0x3f; + size_t used = saved_lo & 0x3f; if (used) { - unsigned long available = 64 - used; + size_t available = 64 - used; if (size < available) { @@ -248,7 +248,7 @@ void winpr_MD5_Update(WINPR_MD5_CTX* ctx, const void* data, unsigned long size) if (size >= 64) { - data = body(ctx, data, size & ~(unsigned long)0x3f); + data = body(ctx, data, size & ~(size_t)0x3f); size &= 0x3f; } @@ -265,11 +265,11 @@ static inline void mdOUT(unsigned char* dst, winpr_MD5_u32plus src) void winpr_MD5_Final(unsigned char* result, WINPR_MD5_CTX* ctx) { - unsigned long used = ctx->lo & 0x3f; + size_t used = ctx->lo & 0x3f; ctx->buffer[used++] = 0x80; - unsigned long available = 64 - used; + size_t available = 64 - used; if (available < 8) { diff --git a/winpr/libwinpr/crypto/md5.h b/winpr/libwinpr/crypto/md5.h index 2056b9a80..a05d0aad0 100644 --- a/winpr/libwinpr/crypto/md5.h +++ b/winpr/libwinpr/crypto/md5.h @@ -42,7 +42,7 @@ typedef struct } WINPR_MD5_CTX; extern void winpr_MD5_Init(WINPR_MD5_CTX* ctx); -extern void winpr_MD5_Update(WINPR_MD5_CTX* ctx, const void* data, unsigned long size); +extern void winpr_MD5_Update(WINPR_MD5_CTX* ctx, const void* data, size_t size); extern void winpr_MD5_Final(unsigned char* result, WINPR_MD5_CTX* ctx); #endif