Skip to content

Commit

Permalink
Fix broken detection of missing or wrong TORRENTZIPPED-... comment
Browse files Browse the repository at this point in the history
The commit listed below introduces a regression where in MigrateZip(),
variable rc would be clobbered when its value is still needed. That
completely breaks handling of zips that should be re-zipped because
of missing or out of date TORRENTZIPPED-... comment.

Rewrite the offending code such that it no longer touches the variable.

Fixes: cf11c90 ("Check for more errors while reading zip entries")
  • Loading branch information
miller-alex committed Mar 4, 2024
1 parent 4f54248 commit 016915e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/trrntzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,20 @@ int MigrateZip(const char *zip_path, const char *pDir, WORKSPACE *ws,

CHECK_DYNAMIC_STRING_ARRAY(ws->FileNameArray, ws->iElements);
// Get the filelist from the zip file in original order in ws->FileNameArray
rc = GetFileList(UnZipHandle, ws);
if (rc != TZ_OK) {
switch (GetFileList(UnZipHandle, ws)) {
case TZ_OK:
break;
case TZ_CRITICAL:
logprint3(stderr, mig->fProcessLog, ErrorLog(ws),
rc == TZ_CRITICAL
? "Error allocating memory!\n"
: "Could not list contents of \"%s\". File is corrupted or "
"contains entries with bad names.\n",
szZipFileName);
"Error allocating memory!\n");
unzClose(UnZipHandle);
return TZ_CRITICAL;
default:
logprint3(stderr, mig->fProcessLog, ErrorLog(ws),
"Could not list contents of \"%s\". File is corrupted or "
"contains entries with bad names.\n", szZipFileName);
unzClose(UnZipHandle);
return rc;
return TZ_ERR;
}
CHECK_DYNAMIC_STRING_ARRAY(ws->FileNameArray, ws->iElements);

Expand Down

0 comments on commit 016915e

Please sign in to comment.