Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Mar 2013 20:57:13 GMT
From:      Brooks Davis <brooks@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 222793 for review
Message-ID:  <201303112057.r2BKvDgQ058903@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@222793?ac=10

Change 222793 by brooks@brooks_zenith on 2013/03/11 20:56:48

	Pull in changes require to build extract_and_verify on ubuntu.
	Fix copyright year.

Affected files ...

.. //depot/projects/ctsrd/beribsd/src/ctsrd/writefile/Makefile#3 edit
.. //depot/projects/ctsrd/beribsd/src/ctsrd/writefile/eav.c#2 edit
.. //depot/projects/ctsrd/beribsd/src/ctsrd/writefile/eav.h#2 edit

Differences ...

==== //depot/projects/ctsrd/beribsd/src/ctsrd/writefile/Makefile#3 (text+ko) ====

@@ -11,6 +11,7 @@
 
 WARNS=	6
 
+CFLAGS+=-DMD5_SUPPORT
 LDADD+=	-lbz2 -lmd -lutil
 
 .include <bsd.prog.mk>

==== //depot/projects/ctsrd/beribsd/src/ctsrd/writefile/eav.c#2 (text+ko) ====

@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2012 SRI International
+ * Copyright (c) 2013 SRI International
  * All rights reserved.
  *
  * This software was developed by SRI International and the University of
@@ -31,12 +31,30 @@
 #include <sys/param.h>
 
 #include <bzlib.h>
+#ifdef MD5_SUPPORT
 #include <md5.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 
 #include "eav.h"
 
+#ifdef __linux__
+#define        roundup2(x, y)  (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
+
+static void *
+reallocf(void *ptr, size_t size)
+{
+	void *tmp;
+
+	tmp = ptr;
+	ptr = realloc(ptr, size);
+	if (ptr == NULL)
+		free(tmp);
+	return (ptr);
+}
+#endif
+
 enum eav_compression
 eav_taste(const unsigned char *buf, off_t len)
 {
@@ -85,6 +103,8 @@
 		return "checksum mismatch";
 	case EAV_ERR_DIGEST_UNKNOWN:
 		return "unknown digest";
+	case EAV_ERR_DIGEST_UNSUPPORTED:
+		return "unsupported digest";
 	case EAV_ERR_COMP:
 		return "decompression error";
 	case EAV_ERR_COMP_UNKNOWN:
@@ -103,11 +123,14 @@
     enum eav_digest dtype, const unsigned char *digest)
 {
 	int ret;
-	char *obuf = NULL;
-	size_t olen = 0, prev_total_in, total_in, total_out;
+	unsigned char *obuf = NULL;
+	size_t olen = 0, total_in, total_out;
 	bz_stream bzs;
+#ifdef MD5_SUPPORT
+	size_t prev_total_in;
 	MD5_CTX md5ctx;
 	char i_md5sum[33];
+#endif
 
 	switch (ctype) {
 	case EAV_COMP_NONE:
@@ -122,15 +145,23 @@
 
 	switch (dtype) {
 	case EAV_DIGEST_NONE:
+		break;
 	case EAV_DIGEST_MD5:
+#ifdef MD5_SUPPORT
 		break;
+#else
+		return (EAV_ERR_DIGEST_UNSUPPORTED);
+#endif
+
 	default:
 		return (EAV_ERR_DIGEST_UNKNOWN);
 	}
 
 	if (dtype || ctype) {
+#ifdef MD5_SUPPORT
 		if (dtype == EAV_DIGEST_MD5)
 			MD5Init(&md5ctx);
+#endif
 
 		if (ctype) {
 			/* XXX: assume bzip2 for now */
@@ -139,14 +170,16 @@
 				return (EAV_ERR_MEM);
 
 			total_in = 0;
+#ifdef MD5_SUPPORT
 			prev_total_in = 0;
+#endif
 
 			bzs.bzalloc = NULL;
 			bzs.bzfree = NULL;
 			bzs.opaque = NULL;
-			bzs.next_in = ibuf;
+			bzs.next_in = (char *)ibuf;
 			bzs.avail_in = MIN(ilen, 1024 * 1024);
-			bzs.next_out = obuf;
+			bzs.next_out = (char *)obuf;
 			bzs.avail_out = olen;
 			if (BZ2_bzDecompressInit(&bzs, 0, 0) != BZ_OK)
 				return (EAV_ERR_COMP);
@@ -164,10 +197,12 @@
 				total_out = ((size_t)bzs.total_out_hi32 << 32) +
 				    bzs.total_out_lo32;
 
+#ifdef MD5_SUPPORT
 				if (dtype == EAV_DIGEST_MD5)
 					MD5Update(&md5ctx, ibuf + prev_total_in,
 					    total_in - prev_total_in);
 				prev_total_in = total_in;
+#endif
 
 				if (bzs.avail_in == 0)
 					bzs.avail_in =
@@ -180,7 +215,7 @@
 						BZ2_bzDecompressEnd(&bzs);
 						return (EAV_ERR_COMP);
 					}
-					bzs.next_out = obuf + total_out;
+					bzs.next_out = (char *)obuf + total_out;
 					bzs.avail_out = olen - total_out;
 				}
 			}
@@ -190,10 +225,12 @@
 			total_out = ((size_t)bzs.total_out_hi32 << 32) +
 			    bzs.total_out_lo32;
 
+#ifdef MD5_SUPPORT
 			/* Push the last read block in the MD5 machine */
 			if (dtype == EAV_DIGEST_MD5)
 				MD5Update(&md5ctx, ibuf + prev_total_in,
 				    total_in - prev_total_in);
+#endif
 
 			/* Round up to blocksize and zero pad */
 			olen = roundup2(total_out, blocksize);
@@ -202,16 +239,20 @@
 				    olen - total_out);
 			/* XXX: realloc to shorten allocation? */
 		} else if (dtype) {
+#ifdef MD5_SUPPORT
 			if (dtype == EAV_DIGEST_MD5)
 				MD5Update(&md5ctx, ibuf, ilen);
+#endif
 		}
 
 		if (dtype) {
+#ifdef MD5_SUPPORT
 			if (dtype == EAV_DIGEST_MD5) {
 				MD5End(&md5ctx, i_md5sum);
 				if (strcmp(digest, i_md5sum) != 0)
 					return (EAV_ERR_DIGEST);
 			}
+#endif
 		}
 	}
 

==== //depot/projects/ctsrd/beribsd/src/ctsrd/writefile/eav.h#2 (text+ko) ====

@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2012 SRI International
+ * Copyright (c) 2013 SRI International
  * All rights reserved.
  *
  * This software was developed by SRI International and the University of
@@ -36,6 +36,7 @@
 	EAV_ERR_MEM,
 	EAV_ERR_DIGEST,
 	EAV_ERR_DIGEST_UNKNOWN,
+	EAV_ERR_DIGEST_UNSUPPORTED,
 	EAV_ERR_COMP,
 	EAV_ERR_COMP_UNKNOWN,
 	EAV_ERR_COMP_UNSUPPORTED



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303112057.r2BKvDgQ058903>