Module Name:    othersrc
Committed By:   agc
Date:           Sun Aug 12 01:42:24 UTC 2012

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

Log Message:
if the mmap(2) fails, read the file with multiple read(2)s

if it succeeds, use the memory array instead.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 othersrc/external/bsd/mat/dist/mat.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/mat/dist/mat.c
diff -u othersrc/external/bsd/mat/dist/mat.c:1.4 othersrc/external/bsd/mat/dist/mat.c:1.5
--- othersrc/external/bsd/mat/dist/mat.c:1.4	Thu Oct 13 17:20:47 2011
+++ othersrc/external/bsd/mat/dist/mat.c	Sun Aug 12 01:42:24 2012
@@ -256,11 +256,11 @@ digest_file(uint8_t *dig, const char *f)
 	size = (size_t)st.st_size;
 	mapped = mmap(NULL, size, PROT_READ, MAP_FILE, fileno(fp), 0);
 	if (mapped == MAP_FAILED) {
-		SHA256_Update(&sha256, mapped, size);
-	} else {
 		while ((cc = read(fileno(fp), buf, sizeof(buf))) > 0) {
 			SHA256_Update(&sha256, (const uint8_t *)buf, (size_t)cc);
 		}
+	} else {
+		SHA256_Update(&sha256, mapped, size);
 	}
 	SHA256_Final(dig, &sha256);
 	if (mapped != MAP_FAILED) {

Reply via email to