apple / swift-foundation

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

Follow up fix for buffer overflow #684

Closed itingliu closed 2 weeks ago

itingliu commented 2 weeks ago

Start the outer buffer with the capacity of initialSize + 1 so later we can null terminate on the index of initialSize, assuming the return length is smaller or equal to initialSize. We don't bother to verify the assumption since that'd be a user error.

Also fix a terrible copy-pasta error: We should null-terminate the inner buffer, not the outer buffer.

Fixed 129806508

jmschonfeld commented 2 weeks ago

@swift-ci please test