Repository navigation
[RarFile] Prevent extraction of entire archive when file does not exist. - #188
Conversation
|
Decision: APPROVE Issues: none Evidence:
Review Details
|
There was a problem hiding this comment.
Decision: APPROVE
kodiai response
Decision: APPROVE
Issues: none
Evidence:
- Early validation prevents extraction:
src/RarFile.cpp:38-45adds a guard that immediately returns nullptr whenGetFileInRar()fails to locate the requested file in the archive, blocking any downstream extraction logic before it can trigger - Proper resource cleanup: The failure path correctly deletes the allocated
RARContext(line 43) before returning nullptr, preventing memory leaks - Graceful fallback in Stat():
src/RarFile.cpp:417-427already handles nullptr returns fromOpen()by falling back toDirectoryExists(), which uses the cheaperGetDirectory/ArchiveListverification path instead of extraction - Root cause eliminated: Without this check, an empty
m_pathinrar(from a non-existent file) would reach the extraction branch, where an emptyfileToExtracttriggersall = truein the extraction engine, causing the entire archive to be unpacked just to answer a stat query (fixes #187) - Safe null handling:
Close()atsrc/RarFile.cpp:204-223safely handles nullptr context (lines 206-208 guard), so theClose(ctx)call at line 427 won't crash whenctxis nullptr - Correct error semantics: The
Stat()function properly returnserrno = ENOENT(line 434) when neither file nor directory exists, maintaining standard POSIX behavior
|
Thanks @garbear Who can merge addon PRs?? |
|
I can merge. I can also cut a new release. Add-on manager will see the new version after a repo update. |
|
Confirmed working by bug reporter - xbmc/xbmc#28768 (comment) |
|
Nice. I'll do a release when I get a chance. |
|
Thanks |
|
Released version 22.0.4-Piers. |
CDirectoryFactory::Create()in Kodi core callsCFile::Stat()on every URL (including the archive root) before choosing an IDirectory.That reaches
CRARFile::Stat() → Open()with an empty m_pathinrar. The old code didn't check whetherGetFileInRar()actually found a matching entry — it fell through to the "must be compressed, cache-extract it" branch regardless, and since the path was empty.ArchiveExtract's fileToExtract.empty()check setall = true, extracting the entire archive (all files) just to answer a stat/exists probe.The fix makes
Open()fail fast when the requested path isn't a real file in the archive, soStat()correctly falls through to its cheap DirectoryExists()/ArchiveList-based check instead.Fix #187