Hacker Newsnew | comments | show | ask | jobs | submitlogin

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.

-----




Applications are open for YC Summer 2015

Guidelines | FAQ | Support | API | Lists | Bookmarklet | DMCA | Y Combinator | Apply | Contact

Search: