File libdkim2.patch of Package dkim

--- libdkim.orig/src/dkimbase.cpp	2008-05-12 12:07:36.000000000 +0200
+++ libdkim/src/dkimbase.cpp	2008-12-18 09:33:28.000000000 +0100
@@ -31,7 +31,6 @@
 
 #include <algorithm>
 
-
 CDKIMBase::CDKIMBase()
 {
 	m_From = NULL;
@@ -125,7 +124,7 @@
 
 	while( p < e )
 	{
-		if( *p != '\n' || m_LinePos == 0 || m_Line[m_LinePos-1] != '\r' )
+		if(*p != '\n' && *p != '\r' )
 		{
 			// add char to line
 			if (m_LinePos >= m_LineSize)
@@ -138,9 +137,7 @@
 		}
 		else
 		{
-			// back up past the CR
-			m_LinePos--;
-
+			if(*p == '\r' && p+1<e && *(p+1)=='\n') p++;
 			if (m_InHeaders)
 			{
 				// process header line
--- libdkim.orig/src/libdkimtest.cpp	2008-05-12 12:08:54.000000000 +0200
+++ libdkim/src/libdkimtest.cpp	2008-12-18 09:35:42.000000000 +0100
@@ -55,8 +55,23 @@
 	return 0;
 }
 
+void usage()
+{
 
-
+	printf( "usage: libdkimtest [-b<allman|ietf|both>] [-c<r|s|t|u>] [-d<domain>] [-l] [-h] [-i<you@yourdomain.com>] [-q] [-s] [-t] [-v] [-x<expire time>] [-z<hash>] <msgfile> <privkeyfile> <outfile>\n");
+	printf( "-b<standard> allman , ietf or both\n");
+	printf( "-c<canonicalization> r for relaxed [DEFAULT], s - simple, t relaxed/simple, u - simple/relaxed\n");
+	printf( "-d<domain> the domain tag, if not provided it will be determined from the sender/from header\n");
+	printf( "-l include body length tag\n");
+	printf( "-h this help\n");
+	printf( "-i<identity> the identity, if not provided it will not be included\n");
+	printf( "-s sign the message\n");
+	printf( "-t include a timestamp tag\n");
+	printf( "-v verify the message\n");
+	printf( "-x<expire_time> the expire time in seconds since epoch ( DEFAULT = current time + 604800)\n\t if set to - then it will not be included");
+	printf( "-z<hash>  1 for sha1, 2 for sha256, 3 for both\n");
+	printf( "-y<selector> the selector tag DEFAULT=MDaemon\n");
+}
 int main(int argc, char* argv[])
 {
 	int n;
@@ -77,13 +92,11 @@
 	time(&t);
 
 	opts.nCanon = DKIM_SIGN_RELAXED;
-	opts.nIncludeBodyLengthTag = 1;
+	opts.nIncludeBodyLengthTag = 0;
 	opts.nIncludeQueryMethod = 0;
 	opts.nIncludeTimeStamp = 0;
 	opts.expireTime = t + 604800;		// expires in 1 week
 	strcpy( opts.szSelector, MYSELECTOR );
-	strcpy( opts.szDomain, MYDOMAIN );
-	strcpy( opts.szIdentity, MYIDENTITY );
 	opts.pfnHeaderCallback = SignThisHeader;
 	strcpy( opts.szRequiredHeaders, "NonExistant" );
 	opts.nIncludeCopiedHeaders = 0;
@@ -92,6 +105,11 @@
 	int nArgParseState = 0;
 	bool bSign = true;
 
+	if(argc<2){
+		usage();
+		exit(1);
+	}
+
 	for( n = 1; n < argc; n++ )
 	{
 		if( argv[n][0] == '-' && strlen(argv[n]) > 1 )
@@ -121,14 +139,16 @@
 				}
 				break;
 
-
+			case 'd': 
+				strncpy(opts.szDomain,(const char*)(argv[n]+2),sizeof(opts.szDomain)-1);
+				break;
 			case 'l':		// body length tag
 				opts.nIncludeBodyLengthTag = 1;
 				break;
 
 
 			case 'h':
-				printf( "usage: \n" );
+				usage();	
 				return 0;
 
 			case 'i':		// identity 
@@ -138,7 +158,7 @@
 				}
 				else
 				{
-					strcpy( opts.szIdentity, argv[n] + 2 );
+					strncpy( opts.szIdentity, argv[n] + 2,sizeof(opts.szIdentity)-1 );
 				}
 				break;
 
@@ -169,6 +189,9 @@
 				}
 				break;
 
+			case 'y':
+				strncpy( opts.szSelector, argv[n]+2, sizeof(opts.szSelector)-1);
+				break;
 
 			case 'z':		// sign w/ sha1, sha256 or both 
 				opts.nHash = atoi( &argv[n][2] );
openSUSE Build Service is sponsored by