[sword-svn] r1876 - trunk/utilities

jansorg at crosswire.org jansorg at crosswire.org
Thu Dec 22 15:33:06 MST 2005


Author: jansorg
Date: 2005-12-22 15:32:54 -0700 (Thu, 22 Dec 2005)
New Revision: 1876

Modified:
   trunk/utilities/osis2mod.cpp
Log:
Fixes to osis2mod. Check for isWritable and a crash fix if the not initialized cipherfilter pointer is deleted. (jansorg)

Modified: trunk/utilities/osis2mod.cpp
===================================================================
--- trunk/utilities/osis2mod.cpp	2005-12-22 10:08:23 UTC (rev 1875)
+++ trunk/utilities/osis2mod.cpp	2005-12-22 22:32:54 UTC (rev 1876)
@@ -30,7 +30,7 @@
 
 using namespace std;
 
-SWText *module;
+SWText *module = 0;
 VerseKey *currentVerse = 0;
 
 
@@ -346,6 +346,7 @@
 		fprintf(stderr, "  createMod   : (default 0): 0 - create  1 - augment\n");
 		fprintf(stderr, "  compressType: (default 0): 0 - no compression  1 - LZSS    2 - Zip\n");
 		fprintf(stderr, "  blockType   : (default 4): 2 - verses  3 - chapters  4 - books\n");
+		fprintf(stderr, "  cipherkey   : ascii string for module encryption\n");
 		exit(-1);
 	}
 
@@ -398,7 +399,7 @@
 		fprintf(stderr, "error: %s: couldn't open input file: %s \n", argv[0], argv[2]);
 		exit(-2);
 	}
-
+	
 	// Do some initialization stuff
 	SWBuf buffer;
 
@@ -409,7 +410,7 @@
 		module = new RawText(argv[1]);	// open our datapath with our RawText driver.
 	}
 
-	SWFilter *cipherFilter;
+	SWFilter *cipherFilter = 0;
 
 	if (!cipherKey.empty()){
 		fprintf(stderr, "Adding cipher filter with phrase: %s\n", cipherKey.c_str() );
@@ -417,6 +418,13 @@
 		module->AddRawFilter(cipherFilter);
 	}
 
+	if (!module->isWritable()) {
+		fprintf(stderr, "The module is not writable. Writing text to it will not work.\nExiting.\n" );
+		exit(-1);
+	}
+	
+
+
 	currentVerse = new VerseKey();
 	currentVerse->AutoNormalize(0);
 	currentVerse->Headings(1);	// turn on mod/testmnt/book/chap headings



More information about the sword-cvs mailing list