From abaa2058c876e666aa034858905f928914b324ff Mon Sep 17 00:00:00 2001 From: tedu Date: Fri, 29 Jul 2016 18:35:45 +0000 Subject: [PATCH] all of the update functions take a size_t. correct type and casts. ok deraadt millert --- bin/md5/md5.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/bin/md5/md5.c b/bin/md5/md5.c index fbe66dca298..2e009519850 100644 --- a/bin/md5/md5.c +++ b/bin/md5/md5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5.c,v 1.84 2015/12/09 19:36:17 mmcc Exp $ */ +/* $OpenBSD: md5.c,v 1.85 2016/07/29 18:35:45 tedu Exp $ */ /* * Copyright (c) 2001,2003,2005-2007,2010,2013,2014 @@ -68,7 +68,7 @@ struct hash_function { int base64; void *ctx; /* XXX - only used by digest_file() */ void (*init)(void *); - void (*update)(void *, const unsigned char *, unsigned int); + void (*update)(void *, const unsigned char *, size_t); void (*final)(unsigned char *, void *); char * (*end)(void *, char *); TAILQ_ENTRY(hash_function) tailq; @@ -81,7 +81,7 @@ struct hash_function { -1, NULL, (void (*)(void *))CKSUM_Init, - (void (*)(void *, const unsigned char *, unsigned int))CKSUM_Update, + (void (*)(void *, const unsigned char *, size_t))CKSUM_Update, (void (*)(unsigned char *, void *))CKSUM_Final, (char *(*)(void *, char *))CKSUM_End }, @@ -92,7 +92,7 @@ struct hash_function { 0, NULL, (void (*)(void *))MD5Init, - (void (*)(void *, const unsigned char *, unsigned int))MD5Update, + (void (*)(void *, const unsigned char *, size_t))MD5Update, (void (*)(unsigned char *, void *))MD5Final, (char *(*)(void *, char *))MD5End }, @@ -103,7 +103,7 @@ struct hash_function { 0, NULL, (void (*)(void *))RMD160Init, - (void (*)(void *, const unsigned char *, unsigned int))RMD160Update, + (void (*)(void *, const unsigned char *, size_t))RMD160Update, (void (*)(unsigned char *, void *))RMD160Final, (char *(*)(void *, char *))RMD160End }, @@ -114,7 +114,7 @@ struct hash_function { 0, NULL, (void (*)(void *))SHA1Init, - (void (*)(void *, const unsigned char *, unsigned int))SHA1Update, + (void (*)(void *, const unsigned char *, size_t))SHA1Update, (void (*)(unsigned char *, void *))SHA1Final, (char *(*)(void *, char *))SHA1End }, @@ -125,7 +125,7 @@ struct hash_function { 0, NULL, (void (*)(void *))SHA224Init, - (void (*)(void *, const unsigned char *, unsigned int))SHA224Update, + (void (*)(void *, const unsigned char *, size_t))SHA224Update, (void (*)(unsigned char *, void *))SHA224Final, (char *(*)(void *, char *))SHA224End }, @@ -137,7 +137,7 @@ struct hash_function { 0, NULL, (void (*)(void *))SHA256Init, - (void (*)(void *, const unsigned char *, unsigned int))SHA256Update, + (void (*)(void *, const unsigned char *, size_t))SHA256Update, (void (*)(unsigned char *, void *))SHA256Final, (char *(*)(void *, char *))SHA256End }, @@ -149,7 +149,7 @@ struct hash_function { 0, NULL, (void (*)(void *))SHA384Init, - (void (*)(void *, const unsigned char *, unsigned int))SHA384Update, + (void (*)(void *, const unsigned char *, size_t))SHA384Update, (void (*)(unsigned char *, void *))SHA384Final, (char *(*)(void *, char *))SHA384End }, @@ -161,7 +161,7 @@ struct hash_function { 0, NULL, (void (*)(void *))SHA512Init, - (void (*)(void *, const unsigned char *, unsigned int))SHA512Update, + (void (*)(void *, const unsigned char *, size_t))SHA512Update, (void (*)(unsigned char *, void *))SHA512Final, (char *(*)(void *, char *))SHA512End }, @@ -423,7 +423,7 @@ digest_string(char *string, struct hash_list *hl) TAILQ_FOREACH(hf, hl, tailq) { hf->init(&context); - hf->update(&context, string, (unsigned int)strlen(string)); + hf->update(&context, string, strlen(string)); digest_end(hf, &context, digest, sizeof(digest), hf->base64); digest_printstr(hf, string, digest); @@ -495,7 +495,7 @@ digest_file(const char *file, struct hash_list *hl, int echo) err(1, "stdout: write error"); } TAILQ_FOREACH(hf, hl, tailq) - hf->update(hf->ctx, data, (unsigned int)nread); + hf->update(hf->ctx, data, nread); } if (ferror(fp)) { warn("%s: read error", file); @@ -683,7 +683,7 @@ digest_filelist(const char *file, struct hash_function *defhash, int selcount, hf->init(&context); while ((nread = fread(data, 1UL, sizeof(data), fp)) > 0) - hf->update(&context, data, (unsigned int)nread); + hf->update(&context, data, nread); if (ferror(fp)) { warn("%s: read error", file); error = 1; @@ -743,7 +743,7 @@ digest_time(struct hash_list *hl, int times) gettimeofday(&start, NULL); hf->init(&context); for (i = 0; i < count; i++) - hf->update(&context, data, TEST_BLOCK_LEN); + hf->update(&context, data, (size_t)TEST_BLOCK_LEN); digest_end(hf, &context, digest, sizeof(digest), hf->base64); gettimeofday(&stop, NULL); timersub(&stop, &start, &res); @@ -782,8 +782,8 @@ digest_test(struct hash_list *hl) for (i = 0; i < 8; i++) { hf->init(&context); - hf->update((void *)&context, test_strings[i], - (unsigned int)strlen(test_strings[i])); + hf->update(&context, test_strings[i], + strlen(test_strings[i])); digest_end(hf, &context, digest, sizeof(digest), hf->base64); digest_printstr(hf, test_strings[i], digest); @@ -793,8 +793,7 @@ digest_test(struct hash_list *hl) memset(buf, 'a', sizeof(buf)); hf->init(&context); for (i = 0; i < 1000; i++) - hf->update(&context, buf, - (unsigned int)sizeof(buf)); + hf->update(&context, buf, sizeof(buf)); digest_end(hf, &context, digest, sizeof(digest), hf->base64); digest_print(hf, "one million 'a' characters", digest); -- 2.20.1