[BlockOutII] Fix crash when showing the highscore screen (rhbz#1154305)
Hans de Goede
jwrdegoede at fedoraproject.org
Wed Oct 22 17:28:28 UTC 2014
commit 37f69c4d5bb27f94165b874661b6f709c545775c
Author: Hans de Goede <hdegoede at redhat.com>
Date: Wed Oct 22 19:28:30 2014 +0200
Fix crash when showing the highscore screen (rhbz#1154305)
BlockOutII-2.3-localtime-null.patch | 47 +++++++++++++++++++++++++++++++++++
BlockOutII.spec | 2 +-
2 files changed, 48 insertions(+), 1 deletions(-)
---
diff --git a/BlockOutII-2.3-localtime-null.patch b/BlockOutII-2.3-localtime-null.patch
new file mode 100644
index 0000000..1d7f411
--- /dev/null
+++ b/BlockOutII-2.3-localtime-null.patch
@@ -0,0 +1,47 @@
+diff -up bl24_lin_src/BlockOut/Utils.cpp~ bl24_lin_src/BlockOut/Utils.cpp
+--- bl24_lin_src/BlockOut/Utils.cpp~ 2014-10-22 19:22:52.103879246 +0200
++++ bl24_lin_src/BlockOut/Utils.cpp 2014-10-22 19:23:12.472335508 +0200
+@@ -93,12 +93,15 @@ char *FormatTime(float seconds) {
+ char *FormatDate(int time) {
+
+ static char ret[32];
+- if( time>0 ) {
+-#ifdef LOCALTIME32
+- struct tm *ts = _localtime32((__time32_t *)&time);
+-#else
+- struct tm *ts = localtime((time_t *)&time);
+-#endif
++ struct tm *ts = NULL;
++ /* Fix 2038 problem on systems with 64 bit time_t without breaking highscore
++ * safefile backward compat (turns it into a 2106 problem). */
++ time_t t = (unsigned int)time;
++
++ if (time != -1)
++ ts = localtime(&t);
++
++ if (ts) {
+ sprintf(ret,"%02d-%02d-%04d %02d:%02d:%02d",ts->tm_mday,ts->tm_mon+1,ts->tm_year+1900,
+ ts->tm_hour,ts->tm_min,ts->tm_sec);
+ } else {
+@@ -116,12 +119,15 @@ char *FormatDate(int time) {
+ char *FormatDateShort(int time) {
+
+ static char ret[32];
+- if( time>0 ) {
+-#ifdef LOCALTIME32
+- struct tm *ts = _localtime32((__time32_t *)&time);
+-#else
+- struct tm *ts = localtime((time_t *)&time);
+-#endif
++ struct tm *ts = NULL;
++ /* Fix 2038 problem on systems with 64 bit time_t without breaking highscore
++ * safefile backward compat (turns it into a 2106 problem). */
++ time_t t = (unsigned int)time;
++
++ if (time != -1)
++ ts = localtime(&t);
++
++ if (ts) {
+ sprintf(ret,"%02d-%02d-%04d",ts->tm_mday,ts->tm_mon+1,ts->tm_year+1900);
+ } else {
+ strcpy(ret,"..........");
diff --git a/BlockOutII.spec b/BlockOutII.spec
index 327a8ca..4e655d9 100644
--- a/BlockOutII.spec
+++ b/BlockOutII.spec
@@ -114,7 +114,7 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%changelog
* Wed Oct 22 2014 Hans de Goede <hdegoede at redhat.com> - 2.4-10
-- Fix crash when localtime() returns NULL (rhbz#1154305)
+- Fix crash when showing the highscore screen (rhbz#1154305)
* Fri Aug 15 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.4-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
More information about the scm-commits
mailing list