commit 463aff9e6fa2f19df5791a03ee2b77f5bc0a4cdd
parent 753e35562fb4f089bf69879691f66ccf0bf881df
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Thu, 16 Jul 2026 17:12:20 +0200
md5/sha builtins: add clarification comments
Diffstat:
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/mhd2/md5_builtin.c b/src/mhd2/md5_builtin.c
@@ -410,7 +410,10 @@ mhd_MD5_blti_update (struct mhd_Md5CtxBlti *restrict ctx,
unpr_d = (const uint8_t *)data;
#ifndef MHD_UNIT_TESTING
- mhd_assert (0 != size);
+ /* The function works fine with empty data, but it is expected
+ that MHD calls it only with real data to process. */
+ mhd_assert ((0 != size)
+ && "A safeguard against an accidental call with missing data");
#endif
/* Note: (count & (mhd_MD5_BLOCK_SIZE-1))
diff --git a/src/mhd2/sha256_builtin.c b/src/mhd2/sha256_builtin.c
@@ -421,7 +421,10 @@ mhd_SHA256_blti_update (struct mhd_Sha256CtxBlti *restrict ctx,
unpr_d = (const uint8_t *)data;
#ifndef MHD_UNIT_TESTING
- mhd_assert (0 != size);
+ /* The function works fine with empty data, but it is expected
+ that MHD calls it only with real data to process. */
+ mhd_assert ((0 != size)
+ && "A safeguard against an accidental call with missing data");
#endif
/* Note: (count & (mhd_SHA256_BLOCK_SIZE-1))
diff --git a/src/mhd2/sha512_256_builtin.c b/src/mhd2/sha512_256_builtin.c
@@ -480,7 +480,10 @@ mhd_SHA512_256_blti_update (struct mhd_Sha512_256CtxBlti *restrict ctx,
unpr_d = (const uint8_t *)data;
#ifndef MHD_UNIT_TESTING
- mhd_assert (0 != size);
+ /* The function works fine with empty data, but it is expected
+ that MHD calls it only with real data to process. */
+ mhd_assert ((0 != size)
+ && "A safeguard against an accidental call with missing data");
#endif
/* Note: (count & (mhd_SHA512_256_BLOCK_SIZE-1))