Closed froller closed 12 years ago
Here's the patch
--- a/src/nyancat.c
+++ b/src/nyancat.c
@@ -350,7 +350,8 @@ int main(int argc, char ** argv) {
/* We are running standalone, retrieve the
* terminal type from the environment. */
char * nterm = getenv("TERM");
- strcpy(term, nterm);
+ if (nterm)
+ strcpy(term, nterm);
}
/*
Huh. I thought I already merged a commit that "fixed" this (it's not necessarily a bug, having $TERM set is mandatory, so says POSIX.1-2008).
Send a pull request with this patch.
xinetd probably doesn't respect POSIX.1-2008 and I got segfaults running nyancat with xinetd. Nevertheless reading from null-pointer is not quite a good practice.
If you're running under xinetd, you really need to get that -t option passed ;)
If neither TERM variable set nor -t option given nyancat crashes with SIG_SEGV.
Probably it does 'cause at nyancat.c:353 it tries to strcpy() from null-pointer nterm.