if (!*ppList)
*ppList = pCurr;
pCurr->item.NameSize = strlen(pArc->NewLhd.FileName);
+ // sanity check - if it fails the archive is likely corrupt
+ if (pCurr->item.NameSize > NM)
+ {
+ File::RemoveCreated();
+ return 0;
+ }
+
pCurr->item.Name = (char *)malloc(pCurr->item.NameSize + 1);
strcpy(pCurr->item.Name, pArc->NewLhd.FileName);
pCurr->item.NameW = (wchar *)malloc((pCurr->item.NameSize + 1)*sizeof(wchar));
break;
}
iOffset = pArc->NextBlockPos;
+ if (iOffset > pArc->FileLength())
+ {
+ File::RemoveCreated();
+ return 0;
+ }
pArc->SeekToNext();
}
if (pCmd->VolSize!=0 && ((pArc->NewLhd.Flags & LHD_SPLIT_AFTER) || (pArc->GetHeaderType()==ENDARC_HEAD && (pArc->EndArcHead.Flags & EARC_NEXT_VOLUME)!=0)))
return( true);
}
else
+ {
+ CLog::Log(LOGWARNING,"%s: rar lib returned no files in archive %s, likely corrupt",__FUNCTION__,strArchive.c_str());
return( false );
+ }
}
bool CRarDirectory::Exists(const char* strPath)