make/make-4.1-rh1277968.patch
Patsy Franklin ec9e7e7c9c Resolves: #1277968
- Handle NULL returns from ttyname().
2015-11-04 16:05:03 -05:00

52 lines
1.8 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

commit 292da6f6867b75a5af7ddbb639a1feae022f438f
Author: Paul Smith <psmith@gnu.org>
Date: Mon Oct 20 01:54:56 2014 -0400
* main.c (main): [SV 43434] Handle NULL returns from ttyname().
diff --git a/main.c b/main.c
index b2d169c..0cdb8a8 100644
--- a/main.c
+++ b/main.c
@@ -1429,13 +1429,18 @@ main (int argc, char **argv, char **envp)
#ifdef HAVE_ISATTY
if (isatty (fileno (stdout)))
if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMOUT")))
- define_variable_cname ("MAKE_TERMOUT", TTYNAME (fileno (stdout)),
- o_default, 0)->export = v_export;
-
+ {
+ const char *tty = TTYNAME (fileno (stdout));
+ define_variable_cname ("MAKE_TERMOUT", tty ? tty : DEFAULT_TTYNAME,
+ o_default, 0)->export = v_export;
+ }
if (isatty (fileno (stderr)))
if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMERR")))
- define_variable_cname ("MAKE_TERMERR", TTYNAME (fileno (stderr)),
- o_default, 0)->export = v_export;
+ {
+ const char *tty = TTYNAME (fileno (stderr));
+ define_variable_cname ("MAKE_TERMERR", tty ? tty : DEFAULT_TTYNAME,
+ o_default, 0)->export = v_export;
+ }
#endif
/* Reset in case the switches changed our minds. */
diff --git a/makeint.h b/makeint.h
index 6223936..2009f41 100644
--- a/makeint.h
+++ b/makeint.h
@@ -436,10 +436,11 @@ extern struct rlimit stack_limit;
/* The number of bytes needed to represent the largest integer as a string. */
#define INTSTR_LENGTH CSTRLEN ("18446744073709551616")
+#define DEFAULT_TTYNAME "true"
#ifdef HAVE_TTYNAME
# define TTYNAME(_f) ttyname (_f)
#else
-# define TTYNAME(_f) "true"
+# define TTYNAME(_f) DEFAULT_TTYNAME
#endif