Qt: minizip and minizip-ng size compatibility issues
MS-DOS Date and MS-DOS Time are packed 16-bit values (https://learn.microsoft.com/en-us/windows/win32/sysinfo/ms-dos-date-and-time) and when combined they make a 32-bit value. In the original minizip that comes with zlib, the combined dosDate parameter is a uLong, which is 64 bits on LP64 platforms. In minizip-ng, it is a uint32_t. At one point, minizip-ng renamed the dosDate struct member of zip_fileinfo to dos_date, but more recent versions changed it back to dosDate for compatibility, except the size remains different, so our compatibility check can't distinguish the size. clang (and possibly other compilers) complain about shortening a 64 bit unsigned long to a uint32_t so make the return value from our qDateToDosDate a uint32_t as it should be to avoid warnings on distributions with minizip-ng Also the maximum year value that can be stored in the format is 127, since it occupies bits 9-15 of the MS-DOS Date. (There was probably some confusion since the maximum year is 2107, but its offset from 1980, not 1900.)
This commit is contained in:
parent
3c0936d83e
commit
87441e45d8
|
@ -182,7 +182,7 @@ bool WiresharkZipHelper::unzip(QString zipFile, QString directory, bool (*fileCh
|
|||
#define UINT32_MAX (0xffffffff)
|
||||
#endif
|
||||
|
||||
static unsigned long qDateToDosDate(QDateTime time)
|
||||
static uint32_t qDateToDosDate(QDateTime time)
|
||||
{
|
||||
QDate ld = time.toLocalTime().date();
|
||||
|
||||
|
@ -197,7 +197,7 @@ static unsigned long qDateToDosDate(QDateTime time)
|
|||
int month = ld.month() - 1;
|
||||
int day = ld.day();
|
||||
|
||||
if (year < 0 || year > 207 || month < 1 || month > 31)
|
||||
if (year < 0 || year > 127 || month < 1 || month > 31)
|
||||
return 0;
|
||||
|
||||
QTime lt = time.toLocalTime().time();
|
||||
|
@ -205,7 +205,7 @@ static unsigned long qDateToDosDate(QDateTime time)
|
|||
unsigned int dosDate = static_cast<unsigned int>((day + (32 * (month + 1)) + (512 * year)));
|
||||
unsigned int dosTime = static_cast<unsigned int>((lt.second() / 2) + (32 * lt.minute()) + (2048 * lt.hour()));
|
||||
|
||||
return dosDate << 16 | dosTime;
|
||||
return (uint32_t)(dosDate << 16 | dosTime);
|
||||
}
|
||||
|
||||
void WiresharkZipHelper::addFileToZip(zipFile zf, QString filepath, QString fileInZip)
|
||||
|
|
Loading…
Reference in New Issue