Added support for "ignore LZW/II length" flag.

Now at version 2.1.0.
This commit is contained in:
Andy McFadden 2005-09-18 02:18:10 +00:00
parent d8b35fd9c6
commit 987ce8855e
6 changed files with 28 additions and 5 deletions

View File

@ -96,6 +96,7 @@ Nu_NuArchiveNew(NuArchive** ppArchive)
(*ppArchive)->valStripHighASCII = false;
/* bug: this can't be set by application! */
(*ppArchive)->valJunkSkipMax = kDefaultJunkSkipMax;
(*ppArchive)->valIgnoreLZW2Len = false;
(*ppArchive)->messageHandlerFunc = gNuGlobalErrorMessageHandler;

View File

@ -1,3 +1,8 @@
2005/09/17 fadden
- Added "kNuValIgnoreLZW2Len" flag, which enables NuLib2 to handle
archives created by an unknown but badly broken program.
- Fixed build for gcc v4.0.
2004/10/11 ***** v2.0.3 shipped *****
2004/09/25 fadden

View File

@ -1200,7 +1200,7 @@ main_loop:
bail:
/*DBUG_LZW(("### end of block\n"));*/
if (inbuf != inbufend) {
if (expectedInputUsed != (unsigned int) -1 && inbuf != inbufend) {
/* data was corrupted; if we keep going this will get worse */
DBUG(("--- inbuf != inbufend in ExpandLZW2 (diff=%d)\n",
inbufend - inbuf));
@ -1481,7 +1481,11 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
if (!isType2) {
err = Nu_ExpandLZW1(lzwState, rleLen);
} else {
if (lzwState->dataInBuffer < lzwLen) {
if (pArchive->valIgnoreLZW2Len) {
/* some badly-formed archives need this -- not sure
what's creating them, possibly a Mac program */
lzwLen = (unsigned int) -1;
} else if (lzwState->dataInBuffer < lzwLen) {
/* rare -- GSHK will do this if you don't let it finish */
err = kNuErrBufferUnderrun;
Nu_ReportError(NU_BLOB, err, "not enough compressed data "

View File

@ -32,8 +32,8 @@ extern "C" {
* fixes.
*/
#define kNuVersionMajor 2
#define kNuVersionMinor 0
#define kNuVersionBug 3
#define kNuVersionMinor 1
#define kNuVersionBug 0
/*
@ -269,7 +269,8 @@ typedef enum NuValueID {
kNuValueMimicSHK = 10,
kNuValueMaskDataless = 11,
kNuValueStripHighASCII = 12,
kNuValueJunkSkipMax = 13
kNuValueJunkSkipMax = 13,
kNuValueIgnoreLZW2Len = 14
} NuValueID;
typedef unsigned long NuValue;

View File

@ -156,6 +156,7 @@ struct NuArchive {
NuValue valOnlyUpdateOlder; /* modify original arc in place? */
NuValue valStripHighASCII; /* during EOL conv, strip hi bit? */
NuValue valJunkSkipMax; /* scan this far for header */
NuValue valIgnoreLZW2Len; /* don't verify LZW/II len field */
/* callback functions */
NuCallback selectionFilterFunc;

View File

@ -62,6 +62,9 @@ Nu_GetValue(NuArchive* pArchive, NuValueID ident, NuValue* pValue)
case kNuValueJunkSkipMax:
*pValue = pArchive->valJunkSkipMax;
break;
case kNuValueIgnoreLZW2Len:
*pValue = pArchive->valIgnoreLZW2Len;
break;
default:
err = kNuErrInvalidArg;
Nu_ReportError(NU_BLOB, err, "Unknown ValueID %d requested", ident);
@ -186,6 +189,14 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
}
pArchive->valJunkSkipMax = value;
break;
case kNuValueIgnoreLZW2Len:
if (value != true && value != false) {
Nu_ReportError(NU_BLOB, err,
"Invalid kNuValueIgnoreLZW2Len value %ld", value);
goto bail;
}
pArchive->valIgnoreLZW2Len = value;
break;
default:
Nu_ReportError(NU_BLOB, err, "Unknown ValueID %d requested", ident);
goto bail;