2 Commits

Author SHA256 Message Date
5a6a0a1c66 Accepting request 1294023 from games
OBS-URL: https://build.opensuse.org/request/show/1294023
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/ninvaders?expand=0&rev=4
2025-07-17 15:19:12 +00:00
74d58b6129 - Backport ninvaders-fix-render-loop.patch: Fix buffer overflow in
render() function. Same as buffer_owerflow.patch, but with fixed
  patchfile name and updated PATCH-FIX-UPSTREAM.
  Adapted from https://sourceforge.net/p/ninvaders/bugs/2/
- Remove buffer_owerflow.patch: Obsoleted by ninvaders-fix-render-loop.patch.
- Modify ninvaders-obey-cflags.patch: Add missing PATCH-FIX-UPSTREAM comment
  in spec file.
- Backport ninvaders-fix-multiple-definitions.patch: Fix link-time
  error from multiple definitions of the same symbols in various
  object files.
  Adapted from https://sourceforge.net/p/ninvaders/bugs/2/
- Add ninvaders-sighandler_t.patch: Fix function signature of the
  signal handler. The correct signature expects an integer argument,
  which is currently missing. Resolves compile-time errors.
- Add ninvaders-fix-doSleep-decl.patch: Harmonize conflicting
  declarations of doSleep(). The function expects an integer argument,
  which is currently missing in the declarations. Resolves compile-time
  errors.
- Refresh existing patches accordingly

OBS-URL: https://build.opensuse.org/package/show/games/ninvaders?expand=0&rev=7
2025-07-17 06:46:23 +00:00
8 changed files with 302 additions and 21 deletions

View File

@@ -1,12 +0,0 @@
diff -rub ninvaders-0.1.1/aliens.c ninvaders-0.1.1-patched/aliens.c
--- ninvaders-0.1.1/aliens.c 2018-12-03 13:58:33.635261642 +0100
+++ ninvaders-0.1.1-patched/aliens.c 2018-12-03 13:58:46.419391088 +0100
@@ -163,7 +163,7 @@
aliens.right=-1;
aliens.bottom=-1;
shipnum=0;
- for (k=0;k<11;k++) {
+ for (k=0;k<ALIENS_MAX_NUMBER_X;k++) {
lowest_ship[k]=-1;
}

View File

@@ -0,0 +1,36 @@
Fixes the compile-time error show below.
globals.c:44:6: error: conflicting types for doSleep; have void(int)
44 | void doSleep(int microseconds)
| ^~~~~~~
In file included from globals.c:27:
globals.h:28:13: note: previous declaration of doSleep with type void(void)
28 | extern void doSleep();
| ^~~~~~~
Index: ninvaders-0.1.1/globals.h
===================================================================
--- ninvaders-0.1.1.orig/globals.h
+++ ninvaders-0.1.1/globals.h
@@ -25,7 +25,7 @@
#ifndef GLOBALS
#define GLOBALS
-extern void doSleep();
+extern void doSleep(int microseconds);
extern void showUsage();
extern void showVersion();
Index: ninvaders-0.1.1/nInvaders.h
===================================================================
--- ninvaders-0.1.1.orig/nInvaders.h
+++ ninvaders-0.1.1/nInvaders.h
@@ -51,7 +51,7 @@ extern int level;
extern int skill_level;
// included from globals.h
-extern void doSleep();
+extern void doSleep(int microseconds);
extern void showUsage();
extern void showVersion();
extern void showGplShort();

View File

@@ -0,0 +1,163 @@
commit 98cab46bff3ff124bb6428698f9987f87eefc619
Author: lmat dartme18@gmail.com
Date: Mon Jan 2 12:25:28 2023 -0500
Corrected compilation errors
gcc -onInvaders globals.o view.o aliens.o ufo.o player.o nInvaders.o -lncurses
/usr/bin/ld: ufo.o:(.bss+0x6d0): multiple definition of `aliens'; aliens.o:(.bss+0x6d0): first defined here
/usr/bin/ld: ufo.o:(.bss+0x0): multiple definition of `skill_level'; aliens.o:(.bss+0x0): first defined here
/usr/bin/ld: ufo.o:(.bss+0x4): multiple definition of `level'; aliens.o:(.bss+0x4): first defined here
/usr/bin/ld: ufo.o:(.bss+0x8): multiple definition of `weite'; aliens.o:(.bss+0x8): first defined here
/usr/bin/ld: ufo.o:(.bss+0x20): multiple definition of `bunker'; aliens.o:(.bss+0x20): first defined here
/usr/bin/ld: ufo.o:(.bss+0x540): multiple definition of `alienBlock'; aliens.o:(.bss+0x540): first defined here
/usr/bin/ld: ufo.o:(.bss+0x608): multiple definition of `alienshotnum'; aliens.o:(.bss+0x608): first defined here
/usr/bin/ld: ufo.o:(.bss+0x620): multiple definition of `alienshoty'; aliens.o:(.bss+0x620): first defined here
/usr/bin/ld: ufo.o:(.bss+0x660): multiple definition of `alienshotx'; aliens.o:(.bss+0x660): first defined here
/usr/bin/ld: ufo.o:(.bss+0x6a0): multiple definition of `lowest_ship'; aliens.o:(.bss+0x6a0): first defined here
/usr/bin/ld: ufo.o:(.bss+0x6c8): multiple definition of `shipnum'; aliens.o:(.bss+0x6c8): first defined here
/usr/bin/ld: player.o:(.bss+0x6f0): multiple definition of `aliens'; aliens.o:(.bss+0x6d0): first defined here
/usr/bin/ld: player.o:(.bss+0x18): multiple definition of `skill_level'; aliens.o:(.bss+0x0): first defined here
/usr/bin/ld: player.o:(.bss+0x6e8): multiple definition of `shipnum'; aliens.o:(.bss+0x6c8): first defined here
/usr/bin/ld: player.o:(.bss+0x1c): multiple definition of `level'; aliens.o:(.bss+0x4): first defined here
/usr/bin/ld: player.o:(.bss+0x20): multiple definition of `weite'; aliens.o:(.bss+0x8): first defined here
/usr/bin/ld: player.o:(.bss+0x28): multiple definition of `ufo'; ufo.o:(.bss+0x6e8): first defined here
/usr/bin/ld: player.o:(.bss+0x40): multiple definition of `bunker'; aliens.o:(.bss+0x20): first defined here
/usr/bin/ld: player.o:(.bss+0x560): multiple definition of `alienBlock'; aliens.o:(.bss+0x540): first defined here
/usr/bin/ld: player.o:(.bss+0x628): multiple definition of `alienshotnum'; aliens.o:(.bss+0x608): first defined here
/usr/bin/ld: player.o:(.bss+0x640): multiple definition of `alienshoty'; aliens.o:(.bss+0x620): first defined here
/usr/bin/ld: player.o:(.bss+0x680): multiple definition of `alienshotx'; aliens.o:(.bss+0x660): first defined here
/usr/bin/ld: player.o:(.bss+0x6c0): multiple definition of `lowest_ship'; aliens.o:(.bss+0x6a0): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6f0): multiple definition of `weite'; aliens.o:(.bss+0x8): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6ec): multiple definition of `level'; aliens.o:(.bss+0x4): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6e8): multiple definition of `skill_level'; aliens.o:(.bss+0x0): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6c8): multiple definition of `shipnum'; aliens.o:(.bss+0x6c8): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x18): multiple definition of `ufo'; ufo.o:(.bss+0x6e8): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x20): multiple definition of `bunker'; aliens.o:(.bss+0x20): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x540): multiple definition of `alienBlock'; aliens.o:(.bss+0x540): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x608): multiple definition of `alienshotnum'; aliens.o:(.bss+0x608): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x620): multiple definition of `alienshoty'; aliens.o:(.bss+0x620): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x660): multiple definition of `alienshotx'; aliens.o:(.bss+0x660): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6a0): multiple definition of `lowest_ship'; aliens.o:(.bss+0x6a0): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6d0): multiple definition of `aliens'; aliens.o:(.bss+0x6d0): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:11: nInvaders] Error 1
---
Index: ninvaders-0.1.1/aliens.c
===================================================================
--- ninvaders-0.1.1.orig/aliens.c
+++ ninvaders-0.1.1/aliens.c
@@ -26,6 +26,19 @@
#include "player.h"
#include "nInvaders.h"
+Aliens aliens;
+
+int shipnum;
+
+// todo: move to structure
+int lowest_ship[ALIENS_MAX_NUMBER_X];
+int alienshotx[ALIENS_MAX_MISSILES];
+int alienshoty[ALIENS_MAX_MISSILES];
+int alienshotnum;
+int alienBlock[ALIENS_MAX_NUMBER_Y][ALIENS_MAX_NUMBER_X];
+
+int bunker[BUNKERHEIGHT][BUNKERWIDTH + 1];
+
/**
* initialize aliens attributes
*/
Index: ninvaders-0.1.1/aliens.h
===================================================================
--- ninvaders-0.1.1.orig/aliens.h
+++ ninvaders-0.1.1/aliens.h
@@ -38,22 +38,22 @@ struct Aliens {
int speed; // 0: no movement; 1: one per turn; etc.
};
-Aliens aliens;
+extern Aliens aliens;
-int shipnum;
+extern int shipnum;
#define ALIENS_MAX_NUMBER_X 10
#define ALIENS_MAX_NUMBER_Y 5
#define ALIENS_MAX_MISSILES 10
// todo: move to structure
-int lowest_ship[ALIENS_MAX_NUMBER_X];
-int alienshotx[ALIENS_MAX_MISSILES];
-int alienshoty[ALIENS_MAX_MISSILES];
-int alienshotnum;
-int alienBlock[ALIENS_MAX_NUMBER_Y][ALIENS_MAX_NUMBER_X];
+extern int lowest_ship[ALIENS_MAX_NUMBER_X];
+extern int alienshotx[ALIENS_MAX_MISSILES];
+extern int alienshoty[ALIENS_MAX_MISSILES];
+extern int alienshotnum;
+extern int alienBlock[ALIENS_MAX_NUMBER_Y][ALIENS_MAX_NUMBER_X];
-int bunker[BUNKERHEIGHT][BUNKERWIDTH + 1];
+extern int bunker[BUNKERHEIGHT][BUNKERWIDTH + 1];
void aliensReset();
Index: ninvaders-0.1.1/nInvaders.c
===================================================================
--- ninvaders-0.1.1.orig/nInvaders.c
+++ ninvaders-0.1.1/nInvaders.c
@@ -32,6 +32,11 @@
#define FPS 50
+// todo: let's try to not having to declare these "public"
+int weite;
+int level;
+int skill_level;
+
int lives;
long score;
int status; // status handled in timer
Index: ninvaders-0.1.1/nInvaders.h
===================================================================
--- ninvaders-0.1.1.orig/nInvaders.h
+++ ninvaders-0.1.1/nInvaders.h
@@ -46,9 +46,9 @@ void drawscore();
void doScoring(int alienType);
// todo: let's try to not having to declare these "public"
-int weite;
-int level;
-int skill_level;
+extern int weite;
+extern int level;
+extern int skill_level;
// included from globals.h
extern void doSleep();
Index: ninvaders-0.1.1/ufo.c
===================================================================
--- ninvaders-0.1.1.orig/ufo.c
+++ ninvaders-0.1.1/ufo.c
@@ -27,6 +27,7 @@
#include "nInvaders.h"
static int fShowUfo = 0;
+Ufo ufo;
/**
* initialize ufo attributes
Index: ninvaders-0.1.1/ufo.h
===================================================================
--- ninvaders-0.1.1.orig/ufo.h
+++ ninvaders-0.1.1/ufo.h
@@ -34,7 +34,7 @@ struct Ufo {
int posY; // vertical position of aliens
};
-Ufo ufo;
+extern Ufo ufo;
void ufoReset();
int ufoShowUfo();

View File

@@ -0,0 +1,35 @@
commit 98cab46bff3ff124bb6428698f9987f87eefc619
Author: lmat dartme18@gmail.com
Date: Mon Jan 2 12:25:28 2023 -0500
Corrected compilation errors
aliens.c: In function render:
aliens.c:167:31: warning: iteration 10 invokes undefined behavior [-Waggressive-loop-optimizations]
167 | lowest_ship[k]=-1;
| ~~~~~~~~~~~~~~^~~
aliens.c:166:19: note: within this loop
166 | for (k=0;k<11;k++) {
| ~^~~
aliens.c:167:31: warning: __builtin_memset forming offset [40, 43] is out of the bounds [0, 40] of object lowest_ship with type int[10] [-Warray-bounds]
167 | lowest_ship[k]=-1;
| ~~~~~~~~~~~~~~^~~
In file included from aliens.c:25:
aliens.h:50:5: note: lowest_ship declared here
50 | int lowest_ship[ALIENS_MAX_NUMBER_X];
| ^~~~~~~~~~~
---
Index: ninvaders-0.1.1/aliens.c
===================================================================
--- ninvaders-0.1.1.orig/aliens.c
+++ ninvaders-0.1.1/aliens.c
@@ -176,7 +176,7 @@ void render()
aliens.right=-1;
aliens.bottom=-1;
shipnum=0;
- for (k=0;k<11;k++) {
+ for (k=0;k<ALIENS_MAX_NUMBER_X;k++) {
lowest_ship[k]=-1;
}

View File

@@ -1,7 +1,7 @@
diff --git a/Makefile b/Makefile
index d815e2f..c68eeeb 100644
--- a/Makefile
+++ b/Makefile
Index: ninvaders-0.1.1/Makefile
===================================================================
--- ninvaders-0.1.1.orig/Makefile
+++ ninvaders-0.1.1/Makefile
@@ -1,5 +1,5 @@
CC=gcc
-CFLAGS=-O3 -Wall

View File

@@ -0,0 +1,21 @@
Fixes the compile-time error show below.
[ 5s] nInvaders.c: In function setUpTimer:
[ 5s] nInvaders.c:323:29: error: assignment to __sighandler_t {aka void (*)(int)} from incompatible pointer type void (*)(void) [-Wincompatible-pointer-types]
[ 5s] 323 | myAction.sa_handler = &handleTimer;
[ 5s] |
---
Index: ninvaders-0.1.1/nInvaders.c
===================================================================
--- ninvaders-0.1.1.orig/nInvaders.c
+++ ninvaders-0.1.1/nInvaders.c
@@ -211,7 +211,7 @@ void readInput()
* timer
* this method is executed every 1 / FPS seconds
*/
-void handleTimer()
+void handleTimer(int signum)
{
static int aliens_move_counter = 0;
static int aliens_shot_counter = 0;

View File

@@ -1,3 +1,35 @@
-------------------------------------------------------------------
Thu Jul 10 12:36:01 UTC 2025 - Thomas Zimmermann <tzimmermann@suse.com>
- Backport ninvaders-fix-render-loop.patch: Fix buffer overflow in
render() function. Same as buffer_owerflow.patch, but with fixed
patchfile name and updated PATCH-FIX-UPSTREAM.
Adapted from https://sourceforge.net/p/ninvaders/bugs/2/
- Remove buffer_owerflow.patch: Obsoleted by ninvaders-fix-render-loop.patch.
- Modify ninvaders-obey-cflags.patch: Add missing PATCH-FIX-UPSTREAM comment
in spec file.
-------------------------------------------------------------------
Thu Jul 10 08:28:40 UTC 2025 - Thomas Zimmermann <tzimmermann@suse.com>
- Backport ninvaders-fix-multiple-definitions.patch: Fix link-time
error from multiple definitions of the same symbols in various
object files.
Adapted from https://sourceforge.net/p/ninvaders/bugs/2/
- Add ninvaders-sighandler_t.patch: Fix function signature of the
signal handler. The correct signature expects an integer argument,
which is currently missing. Resolves compile-time errors.
- Add ninvaders-fix-doSleep-decl.patch: Harmonize conflicting
declarations of doSleep(). The function expects an integer argument,
which is currently missing in the declarations. Resolves compile-time
errors.
- Refresh existing patches accordingly
-------------------------------------------------------------------
Thu Feb 22 14:10:51 UTC 2024 - Dominique Leuenberger <dimstar@opensuse.org>

View File

@@ -1,7 +1,7 @@
#
# spec file for package ninvaders
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -24,10 +24,16 @@ License: GPL-2.0-or-later
Group: Amusements/Games/Action/Arcade
URL: http://ninvaders.sourceforge.net/
Source: http://downloads.sourceforge.net/ninvaders/%{version}/%{name}-%{version}.tar.gz
# PATCH-FIX-OPENSUSE buffer_owerflow.patch
# fix buffer owerflow that leads to an build error in Leap 15+
Patch0: buffer_owerflow.patch
Patch1: ninvaders-obey-cflags.patch
# PATCH-FIX-UPSTREAM ninvaders-fix-multiple-definitions.patch -- upstream bug #2
Patch0: ninvaders-fix-multiple-definitions.patch
# PATCH-FIX-UPSTREAM ninvaders-fix-render-loop.patch -- fix Leap 15+ build error
Patch1: ninvaders-fix-render-loop.patch
# PATCH-FIX-UPSTREAM ninvaders-obey-cflags.patch -- don't clear pre-set CFLAGS
Patch2: ninvaders-obey-cflags.patch
# PATCH-FIX-UPSTREAM ninvaders-sighandler_t.patch -- fix gcc15 build
Patch3: ninvaders-sighandler_t.patch
# PATCH-FIX-UPSTREAM ninvaders-fix-doSleep-decl.patch -- fix gcc15 build
Patch4: ninvaders-fix-doSleep-decl.patch
BuildRequires: ncurses-devel
%description