Group :: Games/Other
RPM: nogravity
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: nogravity--bufer-overflows.patch
Download
Download
--- nogravity-2.00/rlx32/include/systools.h 2005-02-26 00:15:38.000000000 +0100
+++ nogravity-2.00.new/rlx32/include/systools.h 2007-12-30 23:15:14.000000000 +0100
@@ -111,11 +111,12 @@
#define sysMemSet memset
#define sysMemCpy memcpy
#define sysStrCpy strcpy
-#define sysStrnCpy strncpy
#define sysStrLen strlen
#define sysMemZero(a, b) sysMemSet(a, 0, b)
#define sysRand(a) (rand()%(a))
+void sysStrnCpy(char *dest, const char *src, size_t n);
+
#ifndef min
#define min(a,b) ((a)<(b) ? a : b)
#define max(a,b) ((a)>(b) ? a : b)
--- nogravity-2.00/rlx32/src/linux/systime.c 2005-07-10 22:46:28.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/linux/systime.c 2007-12-30 22:08:31.000000000 +0100
@@ -26,6 +26,7 @@
//-------------------------------------------------------------------------
#include <stdio.h>
#include <SDL/SDL.h>
+#include <sched.h>
#include "_rlx32.h"
#include "systools.h"
--- nogravity-2.00/rlx32/src/sysgi.c 2005-06-17 21:59:34.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/sysgi.c 2007-12-30 23:05:29.000000000 +0100
@@ -341,6 +341,10 @@
int ok = 0;
char __temp[256];
unsigned l = strlen(texte);
+
+ if (maxCharacters >= sizeof(__temp))
+ maxCharacters = sizeof(__temp) - 1;
+
sysStrnCpy(__temp, texte, maxCharacters);
do
{
--- nogravity-2.00/rlx32/src/sysresmx.c 2005-06-17 21:59:34.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/sysresmx.c 2007-12-30 23:16:37.000000000 +0100
@@ -26,7 +26,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
-#if defined __GNU_ || __BEOS__
+#if defined __unix__ || defined __GNU__ || defined __BEOS__
#include <unistd.h>
#endif
#if defined _MSC_VER
@@ -65,7 +65,7 @@
}
void MakePathUUU(char *dest, const char *path, const char *lpFilename)
{
- sysStrnCpy(dest, path, _MAX_PATH);
+ sysStrnCpy(dest, path, _MAX_PATH - 2);
AppendTrail(dest);
strcat(dest, lpFilename);
}
@@ -105,7 +105,7 @@
return NULL;
filewad_setcurrent( pWad );
- sysStrnCpy(pWad->s_FileName, lpFilename, _MAX_PATH);
+ sysStrnCpy(pWad->s_FileName, lpFilename, _MAX_PATH - 1);
pWad->mode |= (u_int8_t) flags;
pWad->mode &= ~SYS_WAD_STATUS_ENABLED;
@@ -581,7 +581,7 @@
pWad = filewad_getcurrent();
if (pWad)
- sysStrnCpy(curpath, pWad->s_Path, len);
+ sysStrnCpy(curpath, pWad->s_Path, len - 1);
#if !defined __MACOS__ && !defined _WINCE && !defined SN_TARGET_PS2 && !defined _XBOX
else
getcwd(curpath, len);
--- nogravity-2.00/rlx32/src/systools.c 2007-12-30 23:26:54.000000000 +0100
+++ nogravity-2.00.new/rlx32/src/systools.c 2007-12-30 23:14:22.000000000 +0100
@@ -515,3 +515,10 @@
}
return NULL;
}
+
+void sysStrnCpy(char *dest, const char *src, size_t n)
+{
+ strncpy(dest, src, n);
+ /* important, n must be one less then the actual buffersize ! */
+ dest[n] = 0;
+}
--- nogravity-2.00/rlx32/src/v3xmaps.c 2005-05-29 13:17:06.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/v3xmaps.c 2007-12-30 22:45:21.000000000 +0100
@@ -81,7 +81,7 @@
}
if (bi)
{
- sysStrnCpy(bi->filename, filename, 56);
+ sysStrnCpy(bi->filename, filename, 55);
bi->data = data;
bi->flags |= 1;
bi->type = (u_int8_t)type;
--- nogravity-2.00/rlx32/src/v3xscen2.c 2007-12-30 23:26:54.000000000 +0100
+++ nogravity-2.00.new/rlx32/src/v3xscen2.c 2007-12-30 22:43:40.000000000 +0100
@@ -1649,7 +1649,7 @@
BSWAP16((u_int16_t*)&ori97.index_Parent, 1);
#endif
ori->flags = 0;
- sysStrnCpy(ori->name, ori97.name, 16);
+ sysStrnCpy(ori->name, ori97.name, 15);
ori->type = objTable[ori97.Type];
ori->mesh = ori97.mesh;
ori->morph = ori97.morph;
@@ -2142,7 +2142,7 @@
*ORI = *cORI;
ORI->Cs = NULL;//cORI->Cs;
sprintf(tex, "%s~%x", cOVI->ORI->name, (unsigned)(OVI-pScene->OVI));
- sysStrnCpy(ORI->name, tex, 16);
+ sysStrnCpy(ORI->name, tex, 15);
ORI->flags|=V3XORI_DUPLICATED|V3XORI_CSDUPLICATED;
OVI->index_INSTANCE = cORI - pScene->ORI;
assert(OVI->ORI!=NULL);
--- nogravity-2.00/src/lt_cmx.h 2005-02-24 20:16:40.000000000 +0100
+++ nogravity-2.00.new/src/lt_cmx.h 2007-12-30 23:06:51.000000000 +0100
@@ -25,8 +25,8 @@
//-------------------------------------------------------------------------
typedef struct _sg_script
{
- char Basename[12];
- char Realname[12];
+ char Basename[13];
+ char Realname[13];
int32_t Shield, ShieldMax, Scoring, Sight, Poids;
int32_t Wait, ShootOk, Appear, AfterDeath;
float fSpeed, fFrozen, fSpeedMax;
--- nogravity-2.00/src/lt_info.c 2007-12-30 23:26:54.000000000 +0100
+++ nogravity-2.00.new/src/lt_info.c 2007-12-30 23:10:22.000000000 +0100
@@ -48,7 +48,7 @@
char static *SaveKey(u_int8_t *table)
{
- char tex[256];
+ static char tex[256];
char *s=tex;
int i;
*s = 0;
@@ -63,8 +63,8 @@
static int ReadKey(char *s, u_int8_t *table)
{
- int i, d;
- for (i=0, d=0;i<LK_MAX;i++, s+=3)
+ int i, d, len = strlen(s);
+ for (i=0, d=0;i<LK_MAX && (i*3) < len;i++, s+=3)
{
char te[4];
sysStrnCpy(te, s, 3);
--- nogravity-2.00/src/lt_input.c 2006-01-27 00:39:52.000000000 +0100
+++ nogravity-2.00.new/src/lt_input.c 2007-12-30 22:09:55.000000000 +0100
@@ -25,6 +25,7 @@
//-------------------------------------------------------------------------
#define NG_EXPORT
#include <stdio.h>
+#include <stdlib.h>
#include "_rlx32.h"
#include "sysctrl.h"
#include "systools.h"
--- nogravity-2.00/src/console.c 2009-11-07 12:13:25.000000000 +0100
+++ nogravity-2.00.new/src/console.c 2009-11-07 11:58:20.000000000 +0100
@@ -114,7 +114,7 @@
p = (struct sys_console_item*) malloc (sizeof(struct sys_console_item));
p->prev = 0;
p->next = 0;
- sysStrnCpy(p->text, msg, MAX_SYS_CONSOLE_TEXT);
+ sysStrnCpy(p->text, msg, MAX_SYS_CONSOLE_TEXT-1);
if (!m_pFirst)
m_pFirst = m_pLast = p;
@@ -321,7 +321,7 @@
{
struct sys_console_cmd *p = (struct sys_console_cmd*) malloc(sizeof(struct sys_console_cmd ));
p->next = 0;
- sysStrnCpy(p->szCmd, szCmd, MAX_SYS_CONSOLE_TEXT);
+ sysStrnCpy(p->szCmd, szCmd, MAX_SYS_CONSOLE_TEXT-1);
p->pfFunc = pfFunc;
if (!m_pFirstCmd)
@@ -340,7 +340,7 @@
{
struct sys_console_cvar *p = (struct sys_console_cvar*) malloc(sizeof(struct sys_console_cvar));
p->next = 0;
- sysStrnCpy(p->szVar, szVar, MAX_SYS_CONSOLE_TEXT);
+ sysStrnCpy(p->szVar, szVar, MAX_SYS_CONSOLE_TEXT-1);
p->pData = (void*)pData;
if (!m_pFirstCvar)
--- nogravity-2.00/src/lt_struc.h 2005-02-24 20:16:48.000000000 +0100
+++ nogravity-2.00.new/src/lt_struc.h 2009-11-07 12:06:13.000000000 +0100
@@ -501,7 +501,7 @@
typedef struct {
u_int16_t track, mode;
- char filename[16];
+ char filename[17];
}SGMusic;
enum Ms_Enum