[gap] Fix crash with nameless TTYs, such as in mock shell environments.
Jerry James
jjames at fedoraproject.org
Thu Jan 15 22:11:38 UTC 2015
commit 9f2631a05878018a160f6ca65e39daaac1e4f50a
Author: Jerry James <jamesjer at betterlinux.com>
Date: Thu Jan 15 15:11:49 2015 -0700
Fix crash with nameless TTYs, such as in mock shell environments.
gap-ttyname.patch | 24 ++++++++++++++++++++++++
gap.spec | 9 ++++++++-
2 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/gap-ttyname.patch b/gap-ttyname.patch
new file mode 100644
index 0000000..c8de281
--- /dev/null
+++ b/gap-ttyname.patch
@@ -0,0 +1,24 @@
+--- ./src/system.c.orig 2014-12-09 20:00:00.000000000 -0700
++++ ./src/system.c 2015-01-14 20:00:00.000000000 -0700
+@@ -1831,8 +1831,8 @@ void InitSystem (
+ #if HAVE_TTYNAME
+ syBuf[0].fp = fileno(stdin);
+ syBuf[0].bufno = -1;
+- if ( isatty( fileno(stdin) ) ) {
+- if ( isatty( fileno(stdout) )
++ if ( isatty( fileno(stdin) ) && ttyname(fileno(stdin)) != NULL ) {
++ if ( isatty( fileno(stdout) ) && ttyname(fileno(stdout)) != NULL
+ && ! strcmp( ttyname(fileno(stdin)), ttyname(fileno(stdout)) ) )
+ syBuf[0].echo = fileno(stdout);
+ else
+@@ -1845,8 +1845,8 @@ void InitSystem (
+ }
+ syBuf[1].echo = syBuf[1].fp = fileno(stdout);
+ syBuf[1].bufno = -1;
+- if ( isatty( fileno(stderr) ) ) {
+- if ( isatty( fileno(stdin) )
++ if ( isatty( fileno(stderr) ) && ttyname(fileno(stderr)) != NULL ) {
++ if ( isatty( fileno(stdin) ) && ttyname(fileno(stdin)) != NULL
+ && ! strcmp( ttyname(fileno(stdin)), ttyname(fileno(stderr)) ) )
+ syBuf[2].fp = fileno(stdin);
+ else
diff --git a/gap.spec b/gap.spec
index 3aae91b..7cf7ec2 100644
--- a/gap.spec
+++ b/gap.spec
@@ -6,7 +6,7 @@
Name: gap
Version: %(sed -r "s/r|p/./g" <<< %upstreamver)
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Computational discrete algebra
Group: Applications/Engineering
@@ -35,6 +35,9 @@ Patch2: %{name}-env.patch
# This patch will not be sent upstream. Force use of the 64-bit stat()
# routines to avoid overflow of the inode and size fields.
Patch3: %{name}-stat.patch
+# In mock --shell environments, isatty(0) == true, but ttyname(0) == NULL,
+# leading to a crash. This breaks debugging GAP package test suites.
+Patch4: %{name}-ttyname.patch
BuildRequires: desktop-file-utils
BuildRequires: gmp-devel
@@ -126,6 +129,7 @@ Both syntax highlighting and indentation are supported.
%patch1
%patch2
%patch3
+%patch4
# Replace the CFLAGS and find the math functions
sed -re "s|(gp_cv_prog_cc_cdynoptions=)\"-fpic -Wall -O2|\1\"\$RPM_OPT_FLAGS -fPIC -D_FILE_OFFSET_BITS=64 -DSYS_DEFAULT_PATHS='\"%{gapdir}\"'|" \
@@ -334,6 +338,9 @@ make testinstall
%{_datadir}/vim/vimfiles/syntax/gap.vim
%changelog
+* Thu Jan 15 2015 Jerry James <loganjerry at gmail.com> - 4.7.6-2
+- Fix crash with nameless TTYs, such as in mock shell environments
+
* Wed Dec 10 2014 Jerry James <loganjerry at gmail.com> - 4.7.6-1
- New upstream release
- Fix license handling
More information about the scm-commits
mailing list