leorse / ctools

Some tools to make your C Programs more reliable and profilable.
MIT License
0 stars 0 forks source link

sprintf check #2

Open leorse opened 8 years ago

leorse commented 8 years ago

Problem

After allocating an array, fill it with sprintfmay cause segfault or memory damages if the string generated is larger than the allocate size.

Suggestion

Use some macro/functions to test the resulting size to know if we are about to overfull the allocated zone

Solution?

Use function snprintf (Linux/GNU/Unix only?) or _scprintf(VS only?)

leorse commented 8 years ago

Done for Linux. Have to check in VS