ben-strasser / fast-cpp-csv-parser

fast-cpp-csv-parser
BSD 3-Clause "New" or "Revised" License
2.11k stars 440 forks source link

fix buffer overrun (and corresponding g++ warning message) #84

Closed freddierice closed 5 years ago

freddierice commented 5 years ago

Fixes compiler warning "specified bound 256 equals destination size [-Wstringop-truncation]"

ben-strasser commented 5 years ago

Hi,

thanks for the pull request.

Why is the existing code broken?

Best Regards Ben Strasser

On 7/28/19 10:51 PM, Freddie Rice wrote:

Fixes compiler warning "specified bound 256 equals destination size [-Wstringop-truncation]"


    You can view, comment on, or merge this pull request online at:

https://github.com/ben-strasser/fast-cpp-csv-parser/pull/84

    Commit Summary

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ben-strasser/fast-cpp-csv-parser/pull/84?email_source=notifications&email_token=AC3IBDYD2HM2R2TZTIXSX43QBYBGVA5CNFSM4IHNNDE2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HB5MIZQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AC3IBD4FMRPUVVRYUDCMYD3QBYBGVANCNFSM4IHNNDEQ.

ben-strasser commented 5 years ago

To the best of my understanding, the current code has no buffer overflow at the indicated spot. A "fix" is therefore not necessary.

freddierice commented 5 years ago

Its a bit tricky, but if you read the documentation for strncpy, you'll see that the current code could produce a one byte buffer overflow (null byte overwrite). It won't cause a problem for most compiles, but you never know what combination of -Os and architecture could produce a buggy stack frame.

I just fixed it for myself because I don't like compiler warnings when I compile with -Wall.