array: validate skip/count before array copy sizing#510
Conversation
|
While the fix itself is ok, it's really either to restriected (there are many other similar functions in the code), or not applied in the right place (most functions calls this with I will not accept the PR in it's current form. |
Defensively validate skip and count before array-copy helpers compute allocation or memcpy sizes from (count - skip). Several helpers in src/gl/array.c use this expression when allocating or copying converted vertex/color/texcoord data. If invalid ranges are ever propagated into these helpers, the subtraction can underflow or produce incorrect copy sizes. Add a shared valid_copy_range() helper and apply it consistently at the top of each affected function: - copy_gl_array - copy_gl_array_texcoord - copy_gl_array_quickconvert - copy_gl_array_convert - copy_gl_array_bgra Behavior is unchanged for valid inputs; invalid ranges are rejected early. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
666d918 to
ee11526
Compare
|
Thanks, that makes sense. I agree this should not be fixed narrowly in only I've reworked this as a defensive bounds-hardening change across all the related array-copy helpers. The revised patch adds a shared
I've also updated the PR title and description to frame this as what it is — defensive bounds hardening — rather than overstating the severity. Behavior is unchanged for valid inputs. |
|
Ok, looks better now. |
This defensively validates
skipandcountbefore array-copy helperscompute allocation or memcpy sizes from
(count - skip).Several helpers in
src/gl/array.cuse this expression when allocating orcopying converted vertex/color/texcoord data. If invalid ranges are ever
propagated into these helpers, the subtraction can underflow or produce
incorrect copy sizes.
This patch adds a shared
valid_copy_range()helper and applies itconsistently at the top of each affected function:
copy_gl_arraycopy_gl_array_texcoordcopy_gl_array_quickconvertcopy_gl_array_convertcopy_gl_array_bgraBehavior is unchanged for valid inputs; invalid ranges are rejected early.