Article 5MD7B strcmp behavior

strcmp behavior

by
igadoter
from LinuxQuestions.org on (#5MD7B)
This
Code: int
main(int argc, char *argv[])
{
int res;
res = strcmp("foo", NULL);

exit(EXIT_SUCCESS);
}crashes with segfault while this
Code: int
main(int argc, char *argv[])
{
int res;
res = strcmp(NULL, NULL);

exit(EXIT_SUCCESS);
}does not crash. I have look at man strcmp but there is nothing about handling NULL arguments. I googled little: standard also does not provide such details. I consider this as kind of curiosity but also perhaps vulnerability which can be exploited - I mean passing both values NULL to strcmp.latest?d=yIl2AUoC8zA latest?i=uQT9UHwUqGM:GyCQ7FzULSs:F7zBnMy latest?i=uQT9UHwUqGM:GyCQ7FzULSs:V_sGLiP latest?d=qj6IDK7rITs latest?i=uQT9UHwUqGM:GyCQ7FzULSs:gIN9vFwuQT9UHwUqGM
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments