Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Jan 2014 06:02:26 +0000 (UTC)
From:      Dirk Meyer <dinoex@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r338974 - in head/sysutils/zidrav: . files
Message-ID:  <201401070602.s0762Q7N050991@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dinoex
Date: Tue Jan  7 06:02:26 2014
New Revision: 338974
URL: http://svnweb.freebsd.org/changeset/ports/338974

Log:
  - fix crc problems on 64bit
  - fix crc problems on big endian systems

Added:
  head/sysutils/zidrav/files/patch-core.cpp   (contents, props changed)
  head/sysutils/zidrav/files/patch-core.h   (contents, props changed)
Modified:
  head/sysutils/zidrav/Makefile

Modified: head/sysutils/zidrav/Makefile
==============================================================================
--- head/sysutils/zidrav/Makefile	Tue Jan  7 05:38:26 2014	(r338973)
+++ head/sysutils/zidrav/Makefile	Tue Jan  7 06:02:26 2014	(r338974)
@@ -3,6 +3,7 @@
 
 PORTNAME=	zidrav
 PORTVERSION=	1.2.0
+PORTREVISION=	1
 CATEGORIES=	sysutils
 MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}4unix/${PORTVERSION}
 DISTNAME=	zidrav4unix-${PORTVERSION}
@@ -19,4 +20,18 @@ do-install:
 	${INSTALL_PROGRAM} ${WRKSRC}/zidrav ${STAGEDIR}${PREFIX}/bin/
 	${INSTALL_MAN} ${WRKSRC}/zidrav.1 ${STAGEDIR}${MANPREFIX}/man/man1/
 
+.include <bsd.port.options.mk>
+
+.if ${ARCH} == "i386"
+CFLAGS+=	-Dcrc32_type=long
+.else
+CFLAGS+=	-Dcrc32_type=int
+.endif
+
+.if ${ARCH} == "amd64" || ${ARCH} == "arm" || ${ARCH} == "i386" || ${ARCH} == "ia64"
+.else
+# mips*eb, powerpc, powerpc64 and sparc
+CFLAGS+=	-DCPU_BIGENDIAN
+.endif
+
 .include <bsd.port.mk>

Added: head/sysutils/zidrav/files/patch-core.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/zidrav/files/patch-core.cpp	Tue Jan  7 06:02:26 2014	(r338974)
@@ -0,0 +1,105 @@
+--- core.cpp.orig	2005-05-21 22:16:50.000000000 +0200
++++ core.cpp	2014-01-07 06:41:30.000000000 +0100
+@@ -38,7 +38,7 @@
+ 
+ void be_write32le(iostream &output, char *buf)
+ {
+-	int data;
++	int data = 0;
+ 	data = *(int*)buf;
+ 
+ 	data = SwapBO32(data);
+@@ -48,7 +48,7 @@
+ 
+ void be_read32le(istream &input, char *buf)
+ {
+-	int data;
++	int data = 0;
+ 	input.read((char *)&data, 4);
+ 
+ 	data = SwapBO32(data);
+@@ -59,7 +59,7 @@
+ 
+ 	char	*buffer;
+ 	int		i;
+-	long	crc;
++	crc32_type	crc;
+     short   oldprc = 0;
+     
+ 	output.write( ZC, 8 );
+@@ -105,11 +105,11 @@
+ 
+ void MakePatchCore( istream &cdti, istream &vstr, iostream &output, int cdtlen, int vstrlen, int * efound) {
+ 
+-	long filesize;
+-	long blocksize;
++	long filesize = 0; // reset all 64bit
++	long blocksize = 0; // reset all 64bit
+ 
+-	long crc;
+-	long cdtcrc;
++	crc32_type crc;
++	crc32_type cdtcrc = 0; // reset all 64bit
+ 
+ 	long curbs;
+ 
+@@ -207,12 +207,12 @@
+ 
+ void ApplyPatchCore( istream &cdpi, iostream &pstr, int cdplen, int pstrlen) {
+ 
+-	long filesize;
+-	long blocksize;
++	long filesize = 0; // reset all 64bit
++	long blocksize = 0; // reset all 64bit
+ 
+ 	long curbs = 0;
+ 
+-	long offset;
++	long offset = 0; // reset all 64bit
+ 
+ 	char *buffer = NULL;
+ 
+@@ -266,7 +266,8 @@
+ 
+ 	char minibuff[9];
+ 
+-	long crc;
++	crc32_type crc;
++	crc32_type filecrc = 0; // reset all 64bit
+ 
+ 	buffer = new char[10];
+ 
+@@ -317,12 +318,12 @@
+     }
+ 
+ 	input.seekg( 0 );						// go to the beginning
+-	input.read( buffer, datalen );		// and pull it all
++	input.read( buffer, datalen - 4 );		// and pull it all
++        read32le(input, (char *)&filecrc);
+ 
+ 	CreateChecksum( buffer, datalen - 4, &crc );
+ 
+-	if( crc != int32tole(*(int *)&buffer[ datalen - 4 ]) ) {
+-		delete [] buffer;
++	if( crc != filecrc ) {
+         switch(emsg)
+         {
+             case IDS_UPT_INVCDT:
+@@ -342,7 +343,7 @@
+ void MakeOverallChecksum( iostream &st, long size ) {
+ 
+ 	char *buffer;
+-	long crc;
++	crc32_type crc;
+ 
+     // FIXME: trying to load whole file... again... :(
+ 	buffer = new char[size];
+@@ -367,7 +368,7 @@
+ #define DO8( buffer )  DO4( buffer ); DO4( buffer );
+ #define DO16( buffer )  DO8( buffer ); DO8( buffer );
+ 
+-void CreateChecksum( char *buffer, long size, long *crc ) {
++void CreateChecksum( char *buffer, long size, crc32_type *crc ) {
+ 
+ 	*crc = 0;
+ 

Added: head/sysutils/zidrav/files/patch-core.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/zidrav/files/patch-core.h	Tue Jan  7 06:02:26 2014	(r338974)
@@ -0,0 +1,20 @@
+--- core.h.orig	2005-05-19 22:58:40.000000000 +0200
++++ core.h	2014-01-07 06:40:24.000000000 +0100
+@@ -48,7 +48,7 @@
+ #define QSV		KSigver( ZQ, QVER )
+ 
+ 
+-const long crc_table[256] = {		// it's just easier this way, alright? It's one K of data, I'm allowed a global if I want one
++const crc32_type crc_table[256] = {		// it's just easier this way, alright? It's one K of data, I'm allowed a global if I want one
+   0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+   0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+   0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+@@ -111,7 +111,6 @@
+ int VerifyStream( istream &input, int datalen, int emsg, KSigver sigver );
+ 
+ void MakeOverallChecksum( iostream &st, long size );
+-void CreateChecksum( char *buffer, long size, unsigned long *crc );
+-void CreateChecksum( char *buffer, long size, signed long *crc );
++void CreateChecksum( char *buffer, long size, crc32_type *crc );
+ 
+ #endif



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