Skip to content

Commit 87659d0

Browse files
chencheng maoclaude
andcommitted
Fix crash with NUL character in path given to --file-list
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 43425ee commit 87659d0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎cli/filelister.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ std::string FileLister::addFiles(std::list<FileWithDetails> &files, const std::s
168168
if (path.empty())
169169
return "no path specified";
170170

171+
if (path.find('\0') != std::string::npos)
172+
return "path contains a NUL character";
173+
171174
std::list<FileWithDetails> filesSorted;
172175

173176
std::string err = addFiles2(filesSorted, path, extra, recursive, ignored, debug);
@@ -285,6 +288,9 @@ std::string FileLister::addFiles(std::list<FileWithDetails> &files, const std::s
285288
if (path.empty())
286289
return "no path specified";
287290

291+
if (path.find('\0') != std::string::npos)
292+
return "path contains a NUL character";
293+
288294
std::string corrected_path = path;
289295
if (endsWith(corrected_path, '/'))
290296
corrected_path.erase(corrected_path.end() - 1);

0 commit comments

Comments
 (0)