Hello,
this patch correct the function meltgc_string_hex_md5sum_file_sequence,
it now returns the same than "cat myfile1 myfile2 ... | md5sum".
fread was not correctly used + it looks like you can't mix function
md5_process_bytes and md5_process_blocks.
Pierre Vittet
Index: gcc/melt-runtime.c
===================================================================
--- gcc/melt-runtime.c (revision 176817)
+++ gcc/melt-runtime.c (working copy)
@@ -5426,6 +5426,7 @@ meltgc_string_hex_md5sum_file_sequence (melt_ptr_t
char bufblock[1024]; /* size should be multiple of 64 for md5_process_block
*/
FILE *fil = NULL;
int nbtup = 0;
+ int cnt = 0;
struct md5_ctx ctx = {};
MELT_ENTERFRAME(3, NULL);
#define resv meltfram__.mcfr_varptr[0]
@@ -5456,16 +5457,14 @@ meltgc_string_hex_md5sum_file_sequence (melt_ptr_t
while (!feof (fil))
{
memset (bufblock, 0, sizeof (bufblock));
- if (fread (bufblock, sizeof(bufblock), 1, fil)==1)
+ cnt = fread (bufblock, 1, sizeof(bufblock), fil);
+ if (cnt ==sizeof(bufblock))
{
/* an entire block has been read. */
- md5_process_block (bufblock, sizeof(bufblock), &ctx);
+ md5_process_bytes (bufblock, sizeof(bufblock), &ctx);
}
else
{
- int cnt = fread (bufblock, 1, sizeof(bufblock), fil);
- if (cnt <= 0)
- break;
md5_process_bytes (bufblock, (size_t) cnt, &ctx);
}
}
2011-07-27 Pierre Vittet <pier...@vpittet.com>
* melt-runtime.c (meltgc_string_hex_md5sum_file_sequence):
Correct fread use + only use md5_process_bytes