[xscreensaver] Yet another segv fix (for shadebobs), detected by

Mamoru TASAKA mtasaka at fedoraproject.org
Thu May 1 14:53:28 UTC 2014


commit 1f20813233d08dbc7e7ed47fb6408b599a33e35b
Author: Mamoru TASAKA <mtasaka at fedoraproject.org>
Date:   Thu May 1 23:53:24 2014 +0900

    Yet another segv fix (for shadebobs), detected by
    
      gcc49 -fsanitize=address

 ...n-MoveShadeBob-set-some-marginal-value-fo.patch |   34 ++++++++++++++++++++
 xscreensaver.spec                                  |   10 +++++-
 2 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/xscreensaver-5.26-0012-shadebobs-in-MoveShadeBob-set-some-marginal-value-fo.patch b/xscreensaver-5.26-0012-shadebobs-in-MoveShadeBob-set-some-marginal-value-fo.patch
new file mode 100644
index 0000000..dca58c6
--- /dev/null
+++ b/xscreensaver-5.26-0012-shadebobs-in-MoveShadeBob-set-some-marginal-value-fo.patch
@@ -0,0 +1,34 @@
+From c38805e06925938ec06f70b3bd908f821b3606c0 Mon Sep 17 00:00:00 2001
+From: Mamoru TASAKA <mtasaka at fedoraproject.org>
+Date: Thu, 1 May 2014 00:48:38 +0900
+Subject: [PATCH] shadebobs: in MoveShadeBob set some marginal value for
+ rounding
+
+In MoveShadeBob(), when the absolute values of pShadeBob->nAngle and pShadeBob->nAngleInc are very close and their signness differs, it can happen that pShadeBob->nAngle becomes negative value with very small absolute value, then with st->iDegreeCount, pShadeBob->nAngle becomes the exact value of st->iDegreeCount. In this case, st->anSinTable[ (int)pShadeBob->nAngle ] points to an invalid address.
+
+To aviod this, we set some marginal value for rounding. Note that (int)-0.5 is 0, so it is okay that pShadeBob->nAngle gets negative (unless its value gets no larger than -1).
+---
+ hacks/shadebobs.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/hacks/shadebobs.c b/hacks/shadebobs.c
+index 64fa82c..d1361dd 100644
+--- a/hacks/shadebobs.c
++++ b/hacks/shadebobs.c
+@@ -147,8 +147,11 @@ static void MoveShadeBob( struct state *st, SShadeBob *pShadeBob )
+ 	pShadeBob->nAngle	   += pShadeBob->nAngleInc;
+ 	pShadeBob->nAngleDelta -= pShadeBob->nAngleInc;
+ 
+-	if( pShadeBob->nAngle >= st->iDegreeCount )	pShadeBob->nAngle -= st->iDegreeCount;
+-	else if( pShadeBob->nAngle < 0 )		pShadeBob->nAngle += st->iDegreeCount;
++	/* Since it can happen that nAngle < 0 and nAngle + iDegreeCount >= iDegreeCount
++	   on floating point, we set some marginal value.
++	*/
++	if( pShadeBob->nAngle + 0.5 >= st->iDegreeCount )	pShadeBob->nAngle -= st->iDegreeCount;
++	else if( pShadeBob->nAngle < -0.5 )		pShadeBob->nAngle += st->iDegreeCount;
+ 	
+ 	if( ( pShadeBob->nAngleInc>0.0F  && pShadeBob->nAngleDelta<pShadeBob->nAngleInc ) ||
+ 	    ( pShadeBob->nAngleInc<=0.0F && pShadeBob->nAngleDelta>pShadeBob->nAngleInc ) )
+-- 
+1.9.0
+
diff --git a/xscreensaver.spec b/xscreensaver.spec
index 2728f54..23b074f 100644
--- a/xscreensaver.spec
+++ b/xscreensaver.spec
@@ -10,7 +10,7 @@
 %define split_getimage   1
 %endif
 
-%define fedora_rel    5
+%define fedora_rel    6
 
 %global use_clang_analyze 0
 %global use_cppcheck   0
@@ -87,9 +87,10 @@ Patch106:        xscreensaver-5.26-0006-ya_rand_init-make-integer-unsigned.patch
 Patch107:        xscreensaver-5.26-0007-analyze_display-prevent-oversize-shift.patch
 Patch108:        xscreensaver-5.26-0008-apple2-wait-loading-image-when-timeout.patch
 Patch109:        xscreensaver-5.26-0009-a2_goto-apple.2-fix-clipping-handing.patch
-#Patch106-109: all sent
 Patch110:        xscreensaver-5.26-0010-noseguy-handle-the-case-0-length-string-or-too-long-.patch
 Patch111:        xscreensaver-5.26-0011-xmatrix-fix-one-byte-ahead-access-in-hack_text.patch
+#Patch106-111: all sent
+Patch112:        xscreensaver-5.26-0012-shadebobs-in-MoveShadeBob-set-some-marginal-value-fo.patch
 # Patches end
 Requires:        xscreensaver-base = %{epoch}:%{version}-%{release}
 Requires:        xscreensaver-extras = %{epoch}:%{version}-%{release}
@@ -335,6 +336,7 @@ cat %PATCH108 | %__git am
 cat %PATCH109 | %__git am
 cat %PATCH110 | %__git am
 cat %PATCH111 | %__git am
+cat %PATCH112 | %__git am
 
 change_option(){
    set +x
@@ -940,6 +942,10 @@ exit 0
 %endif
 
 %changelog
+* Thu May  1 2014 Mamoru TASAKA <mtasaka at fedoraproject.org> - 1:5.26-6
+- Yet another segv fix (for shadebobs), detected by
+  gcc49 -fsanitize=address
+
 * Wed Apr 16 2014 Mamoru TASAKA <mtasaka at fedoraproject.org> - 1:5.26-5
 - Yet another segv fix (for noseguy, xmatrix), detected by
   gcc49 -fsanitize=address


More information about the scm-commits mailing list