Hacker News new | comments | show | ask | jobs | submit login

Funny how they use the word "idiot" then use strcmp instead of strncmp for comparison.



Since they're comparing against a literal string, which is guaranteed to be NULL terminated, what's wrong with that?


Apparently it is safe

http://stackoverflow.com/questions/448563/am-i-correct-that-...

However, some people may have the temptation of, when changing the code, replacing it with a non-literal string, or, in a rare case, there's a memory corruption affecting the literal string making it lose the null-termination.


so there's a bug if someone is tempted to modify it and break otherwise correct code ?

i'd be tempted to say that we can apply the same logic to about 100% of code ever written.


Not a bug, but some warning comment might be useful.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: