3 ms·
Using strlcpy is like suppressing the "Division By Zero" exception and have divisions to return a fake value just to let the program run. In some case this cou
by amadvance 13y ago
Using strlcpy is like suppressing the "Division By Zero" exception and have divisions to return a fake value just to let the program run.
In some case this could be even useful, but it's for legacy and sloppy programs that no one bother to really fix.
For anything that requires some minimal level of quality the best option is to make the program to intentionally crash if a buffer overflow condition is detect. Exactly like a "Division By Zero".
- clarry 13y agoFor anything that requires some minimal level of robustness, the best option is not to make the program crash when a string is too long to fit in a buffer. This is not a buffer overflow condition. This is not at all like Division By Zero. EDIT: In your world the kernel could panic because someone tried to open() too long a filename. Or should the application trying to open the file crash instead? And an IRC server would crash because my client sent a message with 513 characters. I would rather detect these conditions and do the right thing.