Skip to content

FileSequenceFunctions : Fix error in ls() for sequences starting with # - #1556

Merged
johnhaddon merged 1 commit into
ImageEngine:RB-10.6from
ivanimanishi:lsFixRB-10.6
Sep 2, 2026
Merged

FileSequenceFunctions : Fix error in ls() for sequences starting with ##1556
johnhaddon merged 1 commit into
ImageEngine:RB-10.6from
ivanimanishi:lsFixRB-10.6

Conversation

@ivanimanishi

Copy link
Copy Markdown
Member

The sequence overload of IECore::ls() could error with:

IndexError: basic_string::substr: __pos (which is 18446744073709551582) > this->size() (which is 4)

when scanning a directory that contained an entry shorter than the sequence's derived suffix. The length guard used
std::min( prefix.size(), suffix.size() ), which let short directory entries pass. The subsequent fileName.size() - suffix.size() is an unsigned subtraction that underflowed to a huge value, which was then passed to std::string::substr.

Replaced the guard with prefix.size() + suffix.size(). Since prefix and suffix are the non-overlapping leading/trailing parts of the name, a match must be at least as long as both combined.

Generally describe what this PR will do, and why it is needed.

  • List specific new features and changes to project components

Related Issues

IECore.ls( fileSequencePath ) could raise an IndexError if the fileSequencePath started with # and the same directory had any files or directories with fewer characters than fileSequencePath.

Checklist

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have tested my change(s) in the test suite, and added new test cases where necessary.
  • My code follows the Cortex project's prevailing coding style and conventions.

The sequence overload of IECore::ls() could error with:
```
IndexError: basic_string::substr: __pos (which is 18446744073709551582) > this->size() (which is 4)
```

when scanning a directory that contained an entry shorter than the
sequence's derived suffix. The length guard used
`std::min( prefix.size(), suffix.size() )`, which let short directory
entries pass. The subsequent `fileName.size() - suffix.size()` is an
unsigned subtraction that underflowed to a huge value, which was then
passed to std::string::substr.

Replaced the guard with `prefix.size() + suffix.size()`. Since prefix
and suffix are the non-overlapping leading/trailing parts of the name, a
match must be at least as long as both combined.
@ivanimanishi
ivanimanishi changed the base branch from main to RB-10.6 September 1, 2026 22:01
@johnhaddon
johnhaddon merged commit db21eed into ImageEngine:RB-10.6 Sep 2, 2026
6 checks passed
@ivanimanishi
ivanimanishi deleted the lsFixRB-10.6 branch September 2, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants