Commit 0d8bf87
committed
erofs: Bound recursion depth in populate_directory to prevent stack overflow
A crafted EROFS image with directory cycles can cause unbounded recursion
in populate_directory(), leading to a stack overflow. Add a depth parameter
and enforce a maximum of PATH_MAX / 2 (2048) levels, matching the
theoretical limit for valid filesystem paths.
Found by cargo-fuzz.
Assisted-by: OpenCode (Claude Opus 4)
Signed-off-by: Colin Walters <walters@verbum.org>1 parent f690c47 commit 0d8bf87
1 file changed
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1007 | 1007 | | |
1008 | 1008 | | |
1009 | 1009 | | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
1010 | 1014 | | |
1011 | 1015 | | |
1012 | 1016 | | |
1013 | 1017 | | |
1014 | 1018 | | |
1015 | 1019 | | |
| 1020 | + | |
1016 | 1021 | | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
1017 | 1026 | | |
1018 | 1027 | | |
1019 | 1028 | | |
1020 | 1029 | | |
1021 | 1030 | | |
1022 | 1031 | | |
1023 | 1032 | | |
1024 | | - | |
| 1033 | + | |
1025 | 1034 | | |
1026 | 1035 | | |
1027 | 1036 | | |
| |||
1090 | 1099 | | |
1091 | 1100 | | |
1092 | 1101 | | |
1093 | | - | |
| 1102 | + | |
1094 | 1103 | | |
1095 | 1104 | | |
1096 | 1105 | | |
| |||
0 commit comments