Commit 5ef4237
authored
* Fix unbounded allocation DoS and VRT path traversal in geotiff
Two security fixes for the geotiff subpackage:
1. Add a configurable max_pixels guard to read_to_array() and all
internal read functions (_read_strips, _read_tiles, _read_cog_http).
A crafted TIFF with fabricated header dimensions could previously
trigger multi-TB allocations. The default limit is 1 billion pixels
(~4 GB for float32 single-band), overridable via max_pixels kwarg.
Fixes #1184.
2. Canonicalize VRT source filenames with os.path.realpath() after
resolving relative paths. Previously, a VRT file with "../" in
SourceFilename could read arbitrary files outside the VRT directory.
Fixes #1185.
* Fix VRT parser test failure on Windows
os.path.realpath() converts Unix-style paths to Windows paths on
Windows (e.g. /data/tile.tif becomes D:\data\tile.tif). Use
os.path.realpath() in the assertion so it matches the production
code's canonicalization on all platforms.
* Fix crop=True dropping boundary pixels when all_touched=True (#1197)
_crop_to_bbox compared pixel center coordinates against the geometry
bounding box without accounting for pixel cell extent. When
all_touched=True, pixels whose centers fell just outside the bbox were
excluded even though their cells overlapped the polygon.
Now _crop_to_bbox receives the all_touched flag and expands the bbox
comparison by half a pixel on each side when set, so rasterize gets to
see every pixel whose cell intersects the geometry.
Also removed dead ascending/descending branches that computed the same
mask regardless of coordinate order.
1 parent 32f28da commit 5ef4237
2 files changed
Lines changed: 76 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
86 | 90 | | |
87 | 91 | | |
88 | 92 | | |
| |||
91 | 95 | | |
92 | 96 | | |
93 | 97 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
102 | 113 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 114 | + | |
| 115 | + | |
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
| |||
186 | 195 | | |
187 | 196 | | |
188 | 197 | | |
189 | | - | |
| 198 | + | |
190 | 199 | | |
191 | 200 | | |
192 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
155 | 191 | | |
156 | 192 | | |
157 | 193 | | |
| |||
207 | 243 | | |
208 | 244 | | |
209 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
210 | 263 | | |
211 | 264 | | |
212 | 265 | | |
| |||
0 commit comments