Bug#987333: jumpnbump crashes on systems with unsigned char.

2021-04-24 Thread peter green

On 22/04/2021 07:23, Fabian Greffrath wrote:

Hi Peter,

Am 22.04.2021 00:52, schrieb peter green:

If I get no response to this bug and I get time to test out the patch
I will likely upload a NMU in a week or so.


the patch looks trivially correct to me. A NMU/Team Upload would be appreciated.


NMU uploaded, debdiff attatched. Will file an unblock request when it is
confirmed that the package is itherwise good for migration.

diff -Nru jumpnbump-1.61/debian/changelog jumpnbump-1.61/debian/changelog
--- jumpnbump-1.61/debian/changelog 2020-07-26 15:48:41.0 +0100
+++ jumpnbump-1.61/debian/changelog 2021-04-24 13:35:52.0 +0100
@@ -1,3 +1,11 @@
+jumpnbump (1.61-3.1) unstable; urgency=medium
+
+  * Non-maintainer upload with maintainers approval.
+  * Apply upstream fix to prevent crash on systems where char is unsigned.
+(Closes: 987333)
+
+ -- Peter Michael Green   Sat, 24 Apr 2021 13:35:52 +0100
+
 jumpnbump (1.61-3) unstable; urgency=medium
 
   * Backport post-release patch from upstream to add future gcc
diff -Nru jumpnbump-1.61/debian/patches/0018-Fix-char-signedness.patch 
jumpnbump-1.61/debian/patches/0018-Fix-char-signedness.patch
--- jumpnbump-1.61/debian/patches/0018-Fix-char-signedness.patch
1970-01-01 01:00:00.0 +0100
+++ jumpnbump-1.61/debian/patches/0018-Fix-char-signedness.patch
2021-04-24 13:29:18.0 +0100
@@ -0,0 +1,32 @@
+commit 8a6873baa395f16048c6865f7036650a3b2bbe76
+Author: Frank Birbacher 
+Date:   Sun Dec 27 12:59:33 2020 +
+
+Fix dj channel signedness
+
+diff --git a/dj.h b/dj.h
+index 07f4a32..985548b 100644
+--- a/dj.h
 b/dj.h
+@@ -115,7 +115,7 @@ extern void dj_mix(void);
+ extern char dj_set_num_sfx_channels(char num_channels);
+ extern void dj_set_sfx_volume(char volume);
+ extern char dj_get_sfx_volume(void);
+-extern void dj_play_sfx(unsigned char sfx_num, unsigned short freq, char 
volume, char panning, unsigned short delay, char channel);
++extern void dj_play_sfx(unsigned char sfx_num, unsigned short freq, char 
volume, char panning, unsigned short delay, signed char channel);
+ extern char dj_get_sfx_settings(unsigned char sfx_num, sfx_data *data);
+ extern char dj_set_sfx_settings(unsigned char sfx_num, sfx_data *data);
+ extern void dj_set_sfx_channel_volume(char channel_num, char volume);
+diff --git a/sdl/sound.c b/sdl/sound.c
+index ff1ee7e..4ea56af 100644
+--- a/sdl/sound.c
 b/sdl/sound.c
+@@ -357,7 +357,7 @@ void dj_set_sfx_volume(char volume)
+   SDL_UnlockAudio();
+ }
+ 
+-void dj_play_sfx(unsigned char sfx_num, unsigned short freq, char volume, 
char panning, unsigned short delay, char channel)
++void dj_play_sfx(unsigned char sfx_num, unsigned short freq, char volume, 
char panning, unsigned short delay, signed char channel)
+ {
+   int slot;
+ 
diff -Nru jumpnbump-1.61/debian/patches/series 
jumpnbump-1.61/debian/patches/series
--- jumpnbump-1.61/debian/patches/series2020-07-26 15:46:24.0 
+0100
+++ jumpnbump-1.61/debian/patches/series2021-04-24 13:30:09.0 
+0100
@@ -1,2 +1,3 @@
 0015-menu-use-Pillow-instead-of-ImageMagick-for-level-pre.patch
 0017-Add-future-gcc-default-fno-common-and-fix-code.patch
+0018-Fix-char-signedness.patch


Bug#987333: jumpnbump crashes on systems with unsigned char.

2021-04-21 Thread Fabian Greffrath

Hi Peter,

Am 22.04.2021 00:52, schrieb peter green:

If I get no response to this bug and I get time to test out the patch
I will likely upload a NMU in a week or so.


the patch looks trivially correct to me. A NMU/Team Upload would be 
appreciated.


Thank you!

Cheers,

 - Fabian



Bug#987333: jumpnbump crashes on systems with unsigned char.

2021-04-21 Thread peter green

Package: jumpnbump
Severity: important

A raspbian user reported that jumpnbump "crashes while jumping", but only
if sound was enabled. The issue was also reported by a ubuntu powerpc user.
(back when ubuntu still supported traditional powerpc)

https://bugs.launchpad.net/ubuntu/+source/jumpnbump/+bug/722370

https://bugs.launchpad.net/raspbian/+bug/1639586

Neither of the original reporters tracked down this issue, but
another raspbian user was able to track it down to a char signedness issue
and has posted a fix upstream at

https://gitlab.com/LibreGames/jumpnbump/-/merge_requests/33/diffs

In the C standard, the signedness of type "char" is implementation defined.
In practice it varies between architectures. on x86* it is signed, but on
arm* and powerpc* it is unsigned.

The result is that when dj_play_sfx is called with the "channel" parameter
set to -1 on an architecture with unsigned char it instead gets interpreted
as 255 resulting in an overflow.

I have not personally tested this issue but I intend to do so soon.

If I get no response to this bug and I get time to test out the patch
I will likely upload a NMU in a week or so.