Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xpilot-ng, bloodspilot-client, boodspilot-server: fix #392353

Merged
merged 3 commits into from
Mar 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkgs/games/xpilot/bloodspilot-client.nix
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@ stdenv.mkDerivation rec {
sha256 = "1qwl95av5an2zl01m7saj6fyy49xpixga7gbn4lwbpgpqs1rbwxj";
};

patches = [ ./bloodspilot-sdl-window-fix.patch ];

buildInputs = [
libX11
SDL
95 changes: 95 additions & 0 deletions pkgs/games/xpilot/bloodspilot-sdl-window-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
--- a/src/client/sdl/scrap.c 2012-09-02 11:25:23.000000000 +0200
+++ b/src/client/sdl/scrap.c 2025-03-23 12:01:51.968751308 +0100
@@ -71,13 +71,13 @@
#if defined(X11_SCRAP)
/* * */
static Display *SDL_Display;
-static Window SDL_Window;
+static Window BloodsPilot_SDL_Window;
static void (*Lock_Display) (void);
static void (*Unlock_Display) (void);

#elif defined(WIN_SCRAP)
/* * */
-static HWND SDL_Window;
+static HWND BloodsPilot_SDL_Window;

#elif defined(QNX_SCRAP)
/* * */
@@ -274,7 +274,7 @@
/* * */
if (info.subsystem == SDL_SYSWM_X11) {
SDL_Display = info.info.x11.display;
- SDL_Window = info.info.x11.window;
+ BloodsPilot_SDL_Window = info.info.x11.window;
Lock_Display = info.info.x11.lock_func;
Unlock_Display = info.info.x11.unlock_func;

@@ -290,7 +290,7 @@

#elif defined(WIN_SCRAP)
/* * */
- SDL_Window = info.window;
+ BloodsPilot_SDL_Window = info.window;
retval = 0;

#elif defined(QNX_SCRAP)
@@ -310,12 +310,12 @@
#if defined(X11_SCRAP)
/* * */
Lock_Display();
- retval = (XGetSelectionOwner(SDL_Display, XA_PRIMARY) != SDL_Window);
+ retval = (XGetSelectionOwner(SDL_Display, XA_PRIMARY) != BloodsPilot_SDL_Window);
Unlock_Display();

#elif defined(WIN_SCRAP)
/* * */
- retval = (GetClipboardOwner() != SDL_Window);
+ retval = (GetClipboardOwner() != BloodsPilot_SDL_Window);

#elif defined(QNX_SCRAP)
/* * */
@@ -346,14 +346,14 @@
(unsigned char *) dst, dstlen);
free(dst);
if (lost_scrap())
- XSetSelectionOwner(SDL_Display, XA_PRIMARY, SDL_Window,
+ XSetSelectionOwner(SDL_Display, XA_PRIMARY, BloodsPilot_SDL_Window,
CurrentTime);
Unlock_Display();
}

#elif defined(WIN_SCRAP)
/* * */
- if (OpenClipboard(SDL_Window)) {
+ if (OpenClipboard(BloodsPilot_SDL_Window)) {
HANDLE hMem;

hMem = GlobalAlloc((GMEM_MOVEABLE | GMEM_DDESHARE), dstlen);
@@ -441,7 +441,7 @@
Lock_Display();
owner = XGetSelectionOwner(SDL_Display, XA_PRIMARY);
Unlock_Display();
- if ((owner == None) || (owner == SDL_Window)) {
+ if ((owner == None) || (owner == BloodsPilot_SDL_Window)) {
owner = DefaultRootWindow(SDL_Display);
selection1 = XA_CUT_BUFFER0;
}
@@ -449,7 +449,7 @@
int selection_response = 0;
SDL_Event event;

- owner = SDL_Window;
+ owner = BloodsPilot_SDL_Window;
Lock_Display();
selection1 = XInternAtom(SDL_Display, "SDL_SELECTION", False);
XConvertSelection(SDL_Display, XA_PRIMARY, format,
@@ -485,7 +485,7 @@

#elif defined(WIN_SCRAP)
/* * */
- if (IsClipboardFormatAvailable(format) && OpenClipboard(SDL_Window)) {
+ if (IsClipboardFormatAvailable(format) && OpenClipboard(BloodsPilot_SDL_Window)) {
HANDLE hMem;
char *src;

40 changes: 40 additions & 0 deletions pkgs/games/xpilot/bloodspilot-server-strcpy-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Fortify catches a possible strcpy overcopy, throw more space at it

--- a/src/server/contact.c 2010-05-24 14:51:41.000000000 +0200
+++ b/src/server/contact.c 2025-03-23 12:15:36.426805646 +0100
@@ -58,11 +58,11 @@

struct queued_player {
struct queued_player *next;
- char real_name[MAX_CHARS];
- char nick_name[MAX_CHARS];
- char disp_name[MAX_CHARS];
- char host_name[MAX_CHARS];
- char host_addr[24];
+ char real_name[MAX_CHARS + 32];
+ char nick_name[MAX_CHARS + 32];
+ char disp_name[MAX_CHARS + 32];
+ char host_name[MAX_CHARS + 32];
+ char host_addr[1056];
int32_t port;
team_t *team;
uint32_t version;
@@ -271,12 +271,12 @@
uint32_t my_magic;
uint16_t port;
char ch;
- char real_name[MAX_CHARS];
- char disp_name[MAX_CHARS];
- char nick_name[MAX_CHARS];
- char host_name[MAX_CHARS];
- char host_addr[24];
- char str[MSG_LEN];
+ char real_name[MAX_CHARS + 32 ];
+ char disp_name[MAX_CHARS + 32 ];
+ char nick_name[MAX_CHARS + 32 ];
+ char host_name[MAX_CHARS + 32 ];
+ char host_addr[1056];
+ char str[MSG_LEN + 32];

/*
* Someone connected to us, now try and decipher the message :)
1 change: 1 addition & 0 deletions pkgs/games/xpilot/bloodspilot-server.nix
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ stdenv.mkDerivation rec {

patches = [
./server-gcc5.patch
./bloodspilot-server-strcpy-fix.patch
];

meta = with lib; {
7 changes: 6 additions & 1 deletion pkgs/games/xpilot/default.nix
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
fetchurl,
libX11,
libSM,
libXext,
SDL,
libGLU,
libGL,
@@ -23,6 +24,7 @@ stdenv.mkDerivation rec {
buildInputs = [
libX11
libSM
libXext
SDL
SDL_ttf
SDL_image
@@ -33,7 +35,10 @@ stdenv.mkDerivation rec {
libXxf86misc
];

patches = [ ./xpilot-ng-gcc-14-fix.patch ];
patches = [
./xpilot-ng-gcc-14-fix.patch
./xpilot-ng-sdl-window-fix.patch
];

meta = with lib; {
description = "Multiplayer X11 space combat game";
96 changes: 96 additions & 0 deletions pkgs/games/xpilot/xpilot-ng-sdl-window-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
XPilot-NG uses SDL_Window (now an SDL type name) as a variable name

--- a/src/client/sdl/scrap.c 2025-03-23 11:48:45.045699445 +0100
+++ b.src/client/sdl/scrap.c 2025-03-23 11:48:48.773699690 +0100
@@ -57,13 +57,13 @@
#if defined(X11_SCRAP)
/* * */
static Display *SDL_Display;
-static Window SDL_Window;
+static Window XPilot_SDL_Window;
static void (*Lock_Display)(void);
static void (*Unlock_Display)(void);

#elif defined(WIN_SCRAP)
/* * */
-static HWND SDL_Window;
+static HWND XPilot_SDL_Window;

#elif defined(QNX_SCRAP)
/* * */
@@ -285,7 +285,7 @@
if ( info.subsystem == SDL_SYSWM_X11 )
{
SDL_Display = info.info.x11.display;
- SDL_Window = info.info.x11.window;
+ XPilot_SDL_Window = info.info.x11.window;
Lock_Display = info.info.x11.lock_func;
Unlock_Display = info.info.x11.unlock_func;

@@ -302,7 +302,7 @@

#elif defined(WIN_SCRAP)
/* * */
- SDL_Window = info.window;
+ XPilot_SDL_Window = info.window;
retval = 0;

#elif defined(QNX_SCRAP)
@@ -323,12 +323,12 @@
#if defined(X11_SCRAP)
/* * */
Lock_Display();
- retval = ( XGetSelectionOwner(SDL_Display, XA_PRIMARY) != SDL_Window );
+ retval = ( XGetSelectionOwner(SDL_Display, XA_PRIMARY) != XPilot_SDL_Window );
Unlock_Display();

#elif defined(WIN_SCRAP)
/* * */
- retval = ( GetClipboardOwner() != SDL_Window );
+ retval = ( GetClipboardOwner() != XPilot_SDL_Window );

#elif defined(QNX_SCRAP)
/* * */
@@ -360,13 +360,13 @@
XA_CUT_BUFFER0, format, 8, PropModeReplace, (unsigned char *)dst, dstlen);
free(dst);
if ( lost_scrap() )
- XSetSelectionOwner(SDL_Display, XA_PRIMARY, SDL_Window, CurrentTime);
+ XSetSelectionOwner(SDL_Display, XA_PRIMARY, XPilot_SDL_Window, CurrentTime);
Unlock_Display();
}

#elif defined(WIN_SCRAP)
/* * */
- if ( OpenClipboard(SDL_Window) )
+ if ( OpenClipboard(XPilot_SDL_Window) )
{
HANDLE hMem;

@@ -461,7 +461,7 @@
Lock_Display();
owner = XGetSelectionOwner(SDL_Display, XA_PRIMARY);
Unlock_Display();
- if ( (owner == None) || (owner == SDL_Window) )
+ if ( (owner == None) || (owner == XPilot_SDL_Window) )
{
owner = DefaultRootWindow(SDL_Display);
selection1 = XA_CUT_BUFFER0;
@@ -471,7 +471,7 @@
int selection_response = 0;
SDL_Event event;

- owner = SDL_Window;
+ owner = XPilot_SDL_Window;
Lock_Display();
selection1 = XInternAtom(SDL_Display, "SDL_SELECTION", False);
XConvertSelection(SDL_Display, XA_PRIMARY, format,
@@ -511,7 +511,7 @@

#elif defined(WIN_SCRAP)
/* * */
- if ( IsClipboardFormatAvailable(format) && OpenClipboard(SDL_Window) )
+ if ( IsClipboardFormatAvailable(format) && OpenClipboard(XPilot_SDL_Window) )
{
HANDLE hMem;
char *src;