bug-freedink
[Top][All Lists]
Advanced

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

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


From: Bas Wijnen
Subject: [Bug-freedink] Bug#826324: Array out of bounds in loop
Date: Sat, 04 Jun 2016 11:17:41 -0400

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]