apple / swift-foundation

The Foundation project
Apache License 2.0
2.28k stars 135 forks source link

Potential stack buffer overflow in `_withFixedCharBuffer` #672

Closed itingliu closed 3 weeks ago

itingliu commented 3 weeks ago

In _withFixedCharBuffer helper, we allocate a buffer with the requested size + 1 (for null-termination). With the assumption that the closure's return value len <= the requested size, the null-terminated character should be on index len, not len + 1.

Fixes rdar://129154192

itingliu commented 3 weeks ago

@swift-ci please test