How can I avoid buffer overflows with C?
June 9, 2007 6:05 AM
Subscribe
Robust usage of sscanf and sprintf - how to avoid buffer overflows?
I am sure this is embarrassingly simple, but all the tutorials I read always gloss over this aspect of sscanf and sprintf. How do I go about ensuring I don't encounter buffer overflows when using these two functions? I've read links like
these that suggest truncating the data, but I don't want to do this.
This link suggests using the "a" flag, but also says it's a GNU-only addition.
How do programmes that don't have fixed-length strings operate? Surely our chat clients don't use fixed-length buffers? Help, Mefi!
posted by PuGZ to computers & internet (23 comments total)
Clearly, there's a possibility that I might use more than 1023 characters. What should I do in such a circumstance?
posted by PuGZ at 6:08 AM on June 9, 2007