Module Name:    othersrc
Committed By:   agc
Date:           Wed Feb  5 17:43:17 UTC 2014

Modified Files:
        othersrc/external/bsd/multigest/dist: multigest.c

Log Message:
give correct results when running the digest when an mmap(2) fails but
read(2) succeeds


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 othersrc/external/bsd/multigest/dist/multigest.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/multigest/dist/multigest.c
diff -u othersrc/external/bsd/multigest/dist/multigest.c:1.6 othersrc/external/bsd/multigest/dist/multigest.c:1.7
--- othersrc/external/bsd/multigest/dist/multigest.c:1.6	Thu Aug 22 01:08:10 2013
+++ othersrc/external/bsd/multigest/dist/multigest.c	Wed Feb  5 17:43:17 2014
@@ -669,6 +669,7 @@ uint8_t *
 multigest_file(const char *alg, const char *f, uint8_t *raw, const char *pat, const char *repl)
 {
 	struct stat	 st;
+	multigest_t	 m;
 	ssize_t		 rc;
 	size_t		 size;
 	size_t		 cc;
@@ -676,6 +677,9 @@ multigest_file(const char *alg, const ch
 	FILE		*fp;
 
 	if (f && alg && raw) {
+                memset(&m, 0x0, sizeof(m));
+                multigest_init(&m, alg);
+                multigest_add_subst(&m, pat, repl);
 		if ((fp = fopen(f, "r")) == NULL) {
 			fprintf(stderr, "can't open '%s'\n", f);
 			return 0;
@@ -689,14 +693,16 @@ multigest_file(const char *alg, const ch
 				if ((rc = read(fileno(fp), mapped, MB(1))) <= 0) {
 					break;
 				}
-				multigest_data(alg, mapped, (size_t)rc, raw, pat, repl);
+				multigest_update(&m, mapped, (size_t)rc);
 			}
 			free(mapped);
 		} else {
-			multigest_data(alg, mapped, size, raw, pat, repl);
+			multigest_update(&m, mapped, (size_t)size);
 			munmap(mapped, size);
 		}
 		fclose(fp);
+                multigest_final(&m, raw);
+                multigest_free(&m);
 		return raw;
 	}
 	return NULL;

Reply via email to