Commit dd1f529
authored
Fix
When destination is a subdirectory of source, `cp_r` would enter an
infinite loop because the newly created destination directory would
be included in the file listing during recursion. This can **cause disk
exhaustion** if large files are present under source.
This adds a validation check that returns `{:error, :einval, destination}`
when copying on a subdir of the source path.
Also document typical error reasons including the new `:einval` case.File.cp_r/3 infinite loop when copying into subdirectory of source (#15148)1 parent 07e6e1a commit dd1f529
2 files changed
Lines changed: 57 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1116 | 1116 | | |
1117 | 1117 | | |
1118 | 1118 | | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
1119 | 1125 | | |
1120 | 1126 | | |
1121 | 1127 | | |
| |||
1146 | 1152 | | |
1147 | 1153 | | |
1148 | 1154 | | |
1149 | | - | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
1150 | 1160 | | |
1151 | 1161 | | |
1152 | 1162 | | |
| |||
1183 | 1193 | | |
1184 | 1194 | | |
1185 | 1195 | | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
1189 | 1206 | | |
1190 | 1207 | | |
1191 | 1208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
799 | 799 | | |
800 | 800 | | |
801 | 801 | | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
802 | 838 | | |
803 | 839 | | |
804 | 840 | | |
| |||
0 commit comments