Bug#826324: [Bug-freedink] Bug#826324: Array out of bounds in loop

Sylvain beuc at beuc.net
Sun Jun 12 16:14:27 UTC 2016


Control: tags -1 fixed-upstream
thanks

Hi,

AFAICS I switched to a '<' in my latest clean-up, probably because I
fixed the same warning.

Cheers!
Sylvain

On Sat, Jun 04, 2016 at 11:17:41AM -0400, Bas Wijnen wrote:
> Package: freedink
> Version: 108.4-1
> Severity: normal
> 
> While compiling the package from the Debian source, I saw a warning about
> undefined behavior, and it is indeed a bug.
> 
> In src/dinkc.c, MAX_CALLBACKS is defined as 100, and callback is defined as
> 
> static struct call_back callback[MAX_CALLBACKS];
> 
> There is a comment on it that says:
> /* TODO: Used 1->100 in the game, should it be MAX_CALLBACKS+1 ? */
> 
> Most of the code uses k < MAX_CALLBACKS to detect the end, so it would work
> (but it would also be one short of what the original game expects; I have not checked if the original is writing out of bounds).
> 
> However, the warning is about line 843, which says k <= MAX_CALLBACKS.
> 
> This is wrong, and there are two possible solutions.
> 
> 1. Change <= into <.  I think this is wrong, because the game expects callback[100] to be valid.
> 2. So instead, the array should be defined as MAX_CALLBACKS + 1 and all the other limit checks should be changed into <=.
> 
> Thanks,
> Bas
> 
> -- System Information:
> Debian Release: stretch/sid
>   APT prefers unstable
>   APT policy: (500, 'unstable')
> Architecture: amd64 (x86_64)
> Foreign Architectures: mipsel, armhf, i386
> 
> Kernel: Linux 4.4.0-1-amd64 (SMP w/2 CPU cores)
> Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
> Init: systemd (via /run/systemd/system)
> 
> Versions of packages freedink depends on:
> ii  freedink-dfarc   3.12-1+b1
> ii  freedink-engine  108.4-1
> 
> freedink recommends no packages.
> 
> freedink suggests no packages.
> 
> -- no debconf information



More information about the Pkg-games-devel mailing list