Commit 3ac35bb0 authored by Olivier Bertrand's avatar Olivier Bertrand

Fix crash when a line is not ended by \n.

  modified:   storage/connect/filamap.cpp

Add specifying a password when reading zipped tables.
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/filamzip.h
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabdos.h

Try Vaintroub suggestion
  modified:   storage/connect/mysql-test/connect/t/jdbc.test
parent 5de5daa7
...@@ -301,9 +301,8 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header) ...@@ -301,9 +301,8 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header)
PDBUSER dup = (PDBUSER)g->Activityp->Aptr; PDBUSER dup = (PDBUSER)g->Activityp->Aptr;
// Skip this record // Skip this record
while (*Mempos++ != '\n') ; // What about Unix ??? while (*Mempos++ != '\n') // What about Unix ???
if (Mempos == Top)
if (Mempos >= Top)
return RC_EF; return RC_EF;
// Update progress information // Update progress information
...@@ -320,7 +319,7 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header) ...@@ -320,7 +319,7 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header)
/***********************************************************************/ /***********************************************************************/
int MAPFAM::ReadBuffer(PGLOBAL g) int MAPFAM::ReadBuffer(PGLOBAL g)
{ {
int rc, len; int rc, len, n = 1;
// Are we at the end of the memory // Are we at the end of the memory
if (Mempos >= Top) { if (Mempos >= Top) {
...@@ -362,10 +361,14 @@ int MAPFAM::ReadBuffer(PGLOBAL g) ...@@ -362,10 +361,14 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
Placed = false; Placed = false;
// Immediately calculate next position (Used by DeleteDB) // Immediately calculate next position (Used by DeleteDB)
while (*Mempos++ != '\n') ; // What about Unix ??? while (*Mempos++ != '\n') // What about Unix ???
if (Mempos == Top) {
n = 0;
break;
} // endif Mempos
// Set caller line buffer // Set caller line buffer
len = (Mempos - Fpos) - 1; len = (Mempos - Fpos) - n;
// Don't rely on ENDING setting // Don't rely on ENDING setting
if (len > 0 && *(Mempos - 2) == '\r') if (len > 0 && *(Mempos - 2) == '\r')
...@@ -619,7 +622,9 @@ int MBKFAM::ReadBuffer(PGLOBAL g) ...@@ -619,7 +622,9 @@ int MBKFAM::ReadBuffer(PGLOBAL g)
} // endif's } // endif's
// Immediately calculate next position (Used by DeleteDB) // Immediately calculate next position (Used by DeleteDB)
while (*Mempos++ != '\n') ; // What about Unix ??? while (*Mempos++ != '\n') // What about Unix ???
if (Mempos == Top)
break;
// Set caller line buffer // Set caller line buffer
len = (Mempos - Fpos) - Ending; len = (Mempos - Fpos) - Ending;
......
...@@ -386,6 +386,7 @@ UNZIPUTL::UNZIPUTL(PSZ tgt, bool mul) ...@@ -386,6 +386,7 @@ UNZIPUTL::UNZIPUTL(PSZ tgt, bool mul)
{ {
zipfile = NULL; zipfile = NULL;
target = tgt; target = tgt;
pwd = NULL;
fp = NULL; fp = NULL;
memory = NULL; memory = NULL;
size = 0; size = 0;
...@@ -401,6 +402,26 @@ UNZIPUTL::UNZIPUTL(PSZ tgt, bool mul) ...@@ -401,6 +402,26 @@ UNZIPUTL::UNZIPUTL(PSZ tgt, bool mul)
#endif #endif
} // end of UNZIPUTL standard constructor } // end of UNZIPUTL standard constructor
UNZIPUTL::UNZIPUTL(PDOSDEF tdp)
{
zipfile = NULL;
target = tdp->GetEntry();
pwd = tdp->Pwd;
fp = NULL;
memory = NULL;
size = 0;
entryopen = false;
multiple = tdp->GetMul();
memset(fn, 0, sizeof(fn));
// Init the case mapping table.
#if defined(__WIN__)
for (int i = 0; i < 256; ++i) mapCaseTable[i] = toupper(i);
#else
for (int i = 0; i < 256; ++i) mapCaseTable[i] = i;
#endif
} // end of UNZIPUTL standard constructor
#if 0 #if 0
UNZIPUTL::UNZIPUTL(PZIPUTIL zutp) UNZIPUTL::UNZIPUTL(PZIPUTIL zutp)
{ {
...@@ -625,7 +646,7 @@ bool UNZIPUTL::openEntry(PGLOBAL g) ...@@ -625,7 +646,7 @@ bool UNZIPUTL::openEntry(PGLOBAL g)
if (rc != UNZ_OK) { if (rc != UNZ_OK) {
sprintf(g->Message, "unzGetCurrentFileInfo64 rc=%d", rc); sprintf(g->Message, "unzGetCurrentFileInfo64 rc=%d", rc);
return true; return true;
} else if ((rc = unzOpenCurrentFile(zipfile)) != UNZ_OK) { } else if ((rc = unzOpenCurrentFilePassword(zipfile, pwd)) != UNZ_OK) {
sprintf(g->Message, "unzOpen fn=%s rc=%d", fn, rc); sprintf(g->Message, "unzOpen fn=%s rc=%d", fn, rc);
return true; return true;
} // endif rc } // endif rc
...@@ -675,15 +696,17 @@ void UNZIPUTL::closeEntry() ...@@ -675,15 +696,17 @@ void UNZIPUTL::closeEntry()
UNZFAM::UNZFAM(PDOSDEF tdp) : MAPFAM(tdp) UNZFAM::UNZFAM(PDOSDEF tdp) : MAPFAM(tdp)
{ {
zutp = NULL; zutp = NULL;
target = tdp->GetEntry(); tdfp = tdp;
mul = tdp->GetMul(); //target = tdp->GetEntry();
//mul = tdp->GetMul();
} // end of UNZFAM standard constructor } // end of UNZFAM standard constructor
UNZFAM::UNZFAM(PUNZFAM txfp) : MAPFAM(txfp) UNZFAM::UNZFAM(PUNZFAM txfp) : MAPFAM(txfp)
{ {
zutp = txfp->zutp; zutp = txfp->zutp;
target = txfp->target; tdfp = txfp->tdfp;
mul = txfp->mul; //target = txfp->target;
//mul = txfp->mul;
} // end of UNZFAM copy constructor } // end of UNZFAM copy constructor
/***********************************************************************/ /***********************************************************************/
...@@ -726,7 +749,7 @@ bool UNZFAM::OpenTableFile(PGLOBAL g) ...@@ -726,7 +749,7 @@ bool UNZFAM::OpenTableFile(PGLOBAL g)
/*********************************************************************/ /*********************************************************************/
/* Allocate the ZIP utility class. */ /* Allocate the ZIP utility class. */
/*********************************************************************/ /*********************************************************************/
zutp = new(g) UNZIPUTL(target, mul); zutp = new(g) UNZIPUTL(tdfp);
// We used the file name relative to recorded datapath // We used the file name relative to recorded datapath
PlugSetPath(filename, To_File, Tdbp->GetPath()); PlugSetPath(filename, To_File, Tdbp->GetPath());
...@@ -841,17 +864,19 @@ void UNZFAM::CloseTableFile(PGLOBAL g, bool) ...@@ -841,17 +864,19 @@ void UNZFAM::CloseTableFile(PGLOBAL g, bool)
UZXFAM::UZXFAM(PDOSDEF tdp) : MPXFAM(tdp) UZXFAM::UZXFAM(PDOSDEF tdp) : MPXFAM(tdp)
{ {
zutp = NULL; zutp = NULL;
target = tdp->GetEntry(); tdfp = tdp;
mul = tdp->GetMul(); //target = tdp->GetEntry();
//mul = tdp->GetMul();
//Lrecl = tdp->GetLrecl(); //Lrecl = tdp->GetLrecl();
} // end of UZXFAM standard constructor } // end of UZXFAM standard constructor
UZXFAM::UZXFAM(PUZXFAM txfp) : MPXFAM(txfp) UZXFAM::UZXFAM(PUZXFAM txfp) : MPXFAM(txfp)
{ {
zutp = txfp->zutp; zutp = txfp->zutp;
target = txfp->target; tdfp = txfp->tdfp;
mul = txfp->mul; //target = txfp->target;
//Lrecl = txfp->Lrecl; //mul = txfp->mul;
//Lrecl = txfp->Lrecl;
} // end of UZXFAM copy constructor } // end of UZXFAM copy constructor
/***********************************************************************/ /***********************************************************************/
...@@ -907,7 +932,7 @@ bool UZXFAM::OpenTableFile(PGLOBAL g) ...@@ -907,7 +932,7 @@ bool UZXFAM::OpenTableFile(PGLOBAL g)
/* Allocate the ZIP utility class. */ /* Allocate the ZIP utility class. */
/*********************************************************************/ /*********************************************************************/
if (!zutp) if (!zutp)
zutp = new(g)UNZIPUTL(target, mul); zutp = new(g)UNZIPUTL(tdfp);
// We used the file name relative to recorded datapath // We used the file name relative to recorded datapath
PlugSetPath(filename, To_File, Tdbp->GetPath()); PlugSetPath(filename, To_File, Tdbp->GetPath());
......
...@@ -45,6 +45,7 @@ class DllExport ZIPUTIL : public BLOCK { ...@@ -45,6 +45,7 @@ class DllExport ZIPUTIL : public BLOCK {
// Members // Members
zipFile zipfile; // The ZIP container file zipFile zipfile; // The ZIP container file
PSZ target; // The target file name PSZ target; // The target file name
PSZ pwd; // The ZIP file password
//unz_file_info finfo; // The current file info //unz_file_info finfo; // The current file info
PFBLOCK fp; PFBLOCK fp;
//char *memory; //char *memory;
...@@ -62,7 +63,7 @@ class DllExport UNZIPUTL : public BLOCK { ...@@ -62,7 +63,7 @@ class DllExport UNZIPUTL : public BLOCK {
public: public:
// Constructor // Constructor
UNZIPUTL(PSZ tgt, bool mul); UNZIPUTL(PSZ tgt, bool mul);
//UNZIPUTL(UNZIPUTL *zutp); UNZIPUTL(PDOSDEF tdp);
// Implementation // Implementation
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); } //PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
...@@ -80,6 +81,7 @@ class DllExport UNZIPUTL : public BLOCK { ...@@ -80,6 +81,7 @@ class DllExport UNZIPUTL : public BLOCK {
// Members // Members
unzFile zipfile; // The ZIP container file unzFile zipfile; // The ZIP container file
PSZ target; // The target file name PSZ target; // The target file name
PSZ pwd; // The ZIP file password
unz_file_info finfo; // The current file info unz_file_info finfo; // The current file info
PFBLOCK fp; PFBLOCK fp;
char *memory; char *memory;
...@@ -119,8 +121,9 @@ class DllExport UNZFAM : public MAPFAM { ...@@ -119,8 +121,9 @@ class DllExport UNZFAM : public MAPFAM {
protected: protected:
// Members // Members
UNZIPUTL *zutp; UNZIPUTL *zutp;
PSZ target; PDOSDEF tdfp;
bool mul; //PSZ target;
//bool mul;
}; // end of UNZFAM }; // end of UNZFAM
/***********************************************************************/ /***********************************************************************/
...@@ -147,8 +150,9 @@ class DllExport UZXFAM : public MPXFAM { ...@@ -147,8 +150,9 @@ class DllExport UZXFAM : public MPXFAM {
protected: protected:
// Members // Members
UNZIPUTL *zutp; UNZIPUTL *zutp;
PSZ target; PDOSDEF tdfp;
bool mul; //PSZ target;
//bool mul;
}; // end of UZXFAM }; // end of UZXFAM
/***********************************************************************/ /***********************************************************************/
......
...@@ -98,6 +98,7 @@ DOSDEF::DOSDEF(void) ...@@ -98,6 +98,7 @@ DOSDEF::DOSDEF(void)
Ofn = NULL; Ofn = NULL;
Entry = NULL; Entry = NULL;
To_Indx = NULL; To_Indx = NULL;
Pwd = NULL;
Recfm = RECFM_VAR; Recfm = RECFM_VAR;
Mapped = false; Mapped = false;
Zipped = false; Zipped = false;
...@@ -139,7 +140,8 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int) ...@@ -139,7 +140,8 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
: false; : false;
Mulentries = GetBoolCatInfo("Mulentries", Mulentries); Mulentries = GetBoolCatInfo("Mulentries", Mulentries);
Append = GetBoolCatInfo("Append", false); Append = GetBoolCatInfo("Append", false);
} Pwd = GetStringCatInfo(g, "Password", NULL);
} // endif Zipped
Desc = Fn = GetStringCatInfo(g, "Filename", NULL); Desc = Fn = GetStringCatInfo(g, "Filename", NULL);
Ofn = GetStringCatInfo(g, "Optname", Fn); Ofn = GetStringCatInfo(g, "Optname", Fn);
......
...@@ -77,6 +77,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */ ...@@ -77,6 +77,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
PSZ Fn; /* Path/Name of corresponding file */ PSZ Fn; /* Path/Name of corresponding file */
PSZ Ofn; /* Base Path/Name of matching index files*/ PSZ Ofn; /* Base Path/Name of matching index files*/
PSZ Entry; /* Zip entry name or pattern */ PSZ Entry; /* Zip entry name or pattern */
PSZ Pwd; /* Zip password */
PIXDEF To_Indx; /* To index definitions blocks */ PIXDEF To_Indx; /* To index definitions blocks */
RECFM Recfm; /* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */ RECFM Recfm; /* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */
bool Mapped; /* 0: disk file, 1: memory mapped file */ bool Mapped; /* 0: disk file, 1: memory mapped file */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment