[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#504704: Crashes on big endian architectures due to incorrect data size used for byte swapping

Package: teeworlds
Version: 0.4.3-1
Severity: important
Tags: patch

Hash: SHA1

Two swap_endian() calls in e_datafile.c pass the size in bytes instead of in
number of units to be swapped, resulting in memory corruption and consequent

The attached patch fixes this and allows teeworlds to work on my PowerBook.

- -- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable'), (102, 'experimental')
Architecture: powerpc (ppc)

Kernel: Linux
Locale: LANG=de_CH.UTF-8, LC_CTYPE=de_CH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages teeworlds depends on:
ii  libc6                  2.7-15            GNU C Library: Shared libraries
ii  libgcc1                1:4.3.2-1         GCC support library
ii  libgl1-mesa-glx [libgl 7.0.3-6           A free implementation of the OpenG
ii  libglu1-mesa [libglu1] 7.0.3-6           The OpenGL utility library (GLU)
ii  libportaudio2          19+svn20071022-3  Portable audio I/O - shared librar
ii  libstdc++6             4.3.2-1           The GNU Standard C++ Library v3
ii  libwavpack1            4.50.1-1          an audio codec (lossy and lossless
ii  libx11-6               2:1.1.5-2         X11 client-side library
ii  libxrandr2             2:1.2.3-1         X11 RandR extension library
ii  teeworlds-data         0.4.3-1           Data for Teeworlds; an online mult
ii  zlib1g                 1: compression library - runtime

teeworlds recommends no packages.

Versions of packages teeworlds suggests:
ii  teeworlds-server              0.4.3-1    Server for Teeworlds; an online mu

- -- no debconf information

Version: GnuPG v1.4.9 (GNU/Linux)

diff -up -ru teeworlds-0.4.3.orig/src/engine/e_datafile.c teeworlds-0.4.3/src/engine/e_datafile.c
--- teeworlds-0.4.3.orig/src/engine/e_datafile.c	2008-11-06 12:19:08.000000000 +0100
+++ teeworlds-0.4.3/src/engine/e_datafile.c	2008-11-06 12:07:02.000000000 +0100
@@ -137,7 +137,7 @@ DATAFILE *datafile_load(const char *file
 #if defined(CONF_ARCH_ENDIAN_BIG)
-	swap_endian(df->data, sizeof(int), header.swaplen);
+	swap_endian(df->data, sizeof(int), header.swaplen/sizeof(int));
@@ -261,7 +261,7 @@ void *datafile_get_data_swapped(DATAFILE
 		return ptr;
 #if defined(CONF_ARCH_ENDIAN_BIG)
-	swap_endian(ptr, sizeof(int), size);
+	swap_endian(ptr, sizeof(int), size/sizeof(int));
 	return ptr;

Reply to: