Make md5 calculation always go through an the buffer so that A) we don't

handle packets out of sequence if some data goes through the buffer and
some doesn't, B) it works on systems that can't handle aligned access,
C) we just have one code path to worry about.

While we're at it, sizeof() and RESERVE_CONFIG_BUFFER() really don't combine
well, which is why md5sum has been reading and processing data 4 bytes at a
time.  I suspect that the existence of CONFIG_MD5_SIZE_VS_SPEED to do loop
unrolling and such in the algorithm was an attempt to work around that bug.
This commit is contained in:
Rob Landley
2006-05-16 02:38:26 +00:00
parent d272dc7cb3
commit 34b5319d86
3 changed files with 45 additions and 90 deletions

View File

@@ -71,7 +71,7 @@ static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
bb_error_msg_and_die("algorithm not supported");
}
while (0 < (count = read(src_fd, in_buf, sizeof in_buf))) {
while (0 < (count = read(src_fd, in_buf, 4096))) {
update(in_buf, count, &context);
}