Commit 07e0f10
committed
fix(duplicatedcontent): hash rootDir in corpusIndexKey
Pass 2 of code review on PR #732 found that corpusIndexKey joined
rootDir into the cache key with the same 0x1f/0x1e control-byte
separators used for include/exclude, but unlike those (YAML-parsed
strings that cannot contain these bytes), rootDir is a raw filesystem
path — most filesystems permit any byte but NUL and '/' in a path
component. A pathological directory name containing a literal
0x1f/0x1e could bleed into the fields that follow it, colliding two
different scopes onto the same RunCache.DuplicateContentIndex slot.
Hash rootDir to a fixed-length hex digest before writing it into the
key: the digest's length and alphabet (0-9a-f) never depend on
rootDir's content, so it can never absorb or be absorbed by an
adjacent field. TestCorpusIndexKey_RootDirControlBytesCannotBleedIntoOtherFields
pins this — confirmed red against the prior unhashed scheme (the
fixed-length assertion failed: 11 vs 26 chars for two different-length
rootDirs) before the fix.1 parent 886c970 commit 07e0f10
2 files changed
Lines changed: 37 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
397 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
398 | 403 | | |
399 | 404 | | |
400 | 405 | | |
401 | 406 | | |
402 | | - | |
| 407 | + | |
| 408 | + | |
403 | 409 | | |
404 | 410 | | |
405 | 411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1034 | 1034 | | |
1035 | 1035 | | |
1036 | 1036 | | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
1037 | 1065 | | |
1038 | 1066 | | |
1039 | 1067 | | |
| |||
0 commit comments