[openjk] 127/130: d/p/Consistently-use-static-QINLINE-for-inline-C-code.patch, d/p/g_svcmds-fix-typo-in-avoiding-non-C-11-compliant-string-s.patch, d/p/savegames-bounds-check-some-string-lengths-to-prevent-buf.patch: more bugfix patches

Simon McVittie smcv at debian.org
Fri Oct 28 11:09:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository openjk.

commit ae0a53c508c46e9c8d4f73a288a9ef1103bcedf9
Author: Simon McVittie <smcv at debian.org>
Date:   Fri Oct 28 11:51:49 2016 +0100

    d/p/Consistently-use-static-QINLINE-for-inline-C-code.patch, d/p/g_svcmds-fix-typo-in-avoiding-non-C-11-compliant-string-s.patch, d/p/savegames-bounds-check-some-string-lengths-to-prevent-buf.patch: more bugfix patches
---
 debian/changelog                                   |   4 +
 ...ntly-use-static-QINLINE-for-inline-C-code.patch |  81 ++++++++
 ...o-in-avoiding-non-C-11-compliant-string-s.patch |  21 +++
 ...-check-some-string-lengths-to-prevent-buf.patch | 207 +++++++++++++++++++++
 debian/patches/series                              |   5 +-
 5 files changed, 317 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index f184d99..02bf03b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,10 @@ openjk (0~20161025+dfsg1-1) UNRELEASED; urgency=medium
     drop, applied upstream
   * d/p/Pick-up-date-from-SOURCE_DATE_EPOCH-for-reproducible-buil.patch:
     alter to define SOURCE_DATE in q_platform.h as requested upstream
+  * d/p/Consistently-use-static-QINLINE-for-inline-C-code.patch,
+    d/p/g_svcmds-fix-typo-in-avoiding-non-C-11-compliant-string-s.patch,
+    d/p/savegames-bounds-check-some-string-lengths-to-prevent-buf.patch:
+    more bugfix patches
 
  -- Simon McVittie <smcv at debian.org>  Fri, 28 Oct 2016 10:57:57 +0100
 
diff --git a/debian/patches/Consistently-use-static-QINLINE-for-inline-C-code.patch b/debian/patches/Consistently-use-static-QINLINE-for-inline-C-code.patch
new file mode 100644
index 0000000..4a201ee
--- /dev/null
+++ b/debian/patches/Consistently-use-static-QINLINE-for-inline-C-code.patch
@@ -0,0 +1,81 @@
+From: Simon McVittie <smcv at debian.org>
+Date: Sun, 25 Sep 2016 22:11:27 +0100
+Subject: Consistently use "static QINLINE" for inline C code
+
+The portable idiom for type-safe macro-like constructs in C is to use
+"static inline" where C99 inline is supported, or "static __inline"
+on compilers that implement that keyword as a compiler-specific
+extension (at least gcc, clang and MSVC do), falling back to just
+"static" as a last resort on terrible compilers from the distant past.
+
+Using "static QINLINE" everywhere means there is no point in defining
+QINLINE to "static inline" on clang, so stop doing that; QINLINE now
+consistently expands to Standard C/C++ inline, or __inline on MSVC,
+or to nothing if we don't know how to inline functions on this
+compiler.
+
+This silences warnings about redundant qualifiers (static static inline)
+for all the functions that were already inline.
+
+There are a couple of uses of non-static QINLINE in C++ code; I've
+left those intact, since inline has different (more useful)
+semantics in C++, and as far as I'm aware all reasonable C++ compilers
+implement it correctly.
+---
+ codemp/game/NPC_move.c      | 4 ++--
+ codemp/game/bg_pmove.c      | 2 +-
+ shared/qcommon/q_platform.h | 6 +-----
+ 3 files changed, 4 insertions(+), 8 deletions(-)
+
+diff --git a/codemp/game/NPC_move.c b/codemp/game/NPC_move.c
+index 7fe0842..5809909 100644
+--- a/codemp/game/NPC_move.c
++++ b/codemp/game/NPC_move.c
+@@ -95,7 +95,7 @@ NPC_CheckCombatMove
+ -------------------------
+ */
+ 
+-QINLINE qboolean NPC_CheckCombatMove( void )
++static QINLINE qboolean NPC_CheckCombatMove( void )
+ {
+ 	//return NPCInfo->combatMove;
+ 	if ( ( NPCS.NPCInfo->goalEntity && NPCS.NPC->enemy && NPCS.NPCInfo->goalEntity == NPCS.NPC->enemy ) || ( NPCS.NPCInfo->combatMove ) )
+@@ -143,7 +143,7 @@ NPC_GetMoveInformation
+ -------------------------
+ */
+ 
+-QINLINE qboolean NPC_GetMoveInformation( vec3_t dir, float *distance )
++static QINLINE qboolean NPC_GetMoveInformation( vec3_t dir, float *distance )
+ {
+ 	//NOTENOTE: Use path stacks!
+ 
+diff --git a/codemp/game/bg_pmove.c b/codemp/game/bg_pmove.c
+index 9b0b9ee..62ac9c8 100644
+--- a/codemp/game/bg_pmove.c
++++ b/codemp/game/bg_pmove.c
+@@ -259,7 +259,7 @@ qboolean BG_KnockDownable(playerState_t *ps)
+ }
+ 
+ //hacky assumption check, assume any client non-humanoid is a rocket trooper
+-qboolean QINLINE PM_IsRocketTrooper(void)
++static QINLINE qboolean PM_IsRocketTrooper(void)
+ {
+ 	/*
+ 	if (pm->ps->clientNum < MAX_CLIENTS &&
+diff --git a/shared/qcommon/q_platform.h b/shared/qcommon/q_platform.h
+index 9e1067a..4f9ee54 100644
+--- a/shared/qcommon/q_platform.h
++++ b/shared/qcommon/q_platform.h
+@@ -123,11 +123,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
+ 		#define OS_STRING "kFreeBSD"
+ 	#endif
+ 
+-	#ifdef __clang__
+-		#define QINLINE static inline
+-	#else
+-		#define QINLINE inline
+-	#endif
++	#define QINLINE inline
+ 
+ 	#define PATH_SEP '/'
+ 
diff --git a/debian/patches/g_svcmds-fix-typo-in-avoiding-non-C-11-compliant-string-s.patch b/debian/patches/g_svcmds-fix-typo-in-avoiding-non-C-11-compliant-string-s.patch
new file mode 100644
index 0000000..a6a4e71
--- /dev/null
+++ b/debian/patches/g_svcmds-fix-typo-in-avoiding-non-C-11-compliant-string-s.patch
@@ -0,0 +1,21 @@
+From: Simon McVittie <smcv at debian.org>
+Date: Fri, 28 Oct 2016 10:23:06 +0100
+Subject: g_svcmds: fix typo in avoiding non-C++11-compliant string syntax
+
+---
+ code/game/g_svcmds.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/code/game/g_svcmds.cpp b/code/game/g_svcmds.cpp
+index 1ef8388..6c2174a 100644
+--- a/code/game/g_svcmds.cpp
++++ b/code/game/g_svcmds.cpp
+@@ -581,7 +581,7 @@ void Svcmd_SaberAttackCycle_f( void )
+ 		//LIGHTSABERCOMBATSTYLE_TAVION
+ 		break;
+ 	case SS_STAFF:
+-		gi.Printf( S_COLOR_MAGENTA" Lightsaber Combat Style: Staff\n" );
++		gi.Printf( S_COLOR_MAGENTA "Lightsaber Combat Style: Staff\n" );
+ 		//LIGHTSABERCOMBATSTYLE_TAVION
+ 		break;
+ 	}
diff --git a/debian/patches/savegames-bounds-check-some-string-lengths-to-prevent-buf.patch b/debian/patches/savegames-bounds-check-some-string-lengths-to-prevent-buf.patch
new file mode 100644
index 0000000..54d6d3c
--- /dev/null
+++ b/debian/patches/savegames-bounds-check-some-string-lengths-to-prevent-buf.patch
@@ -0,0 +1,207 @@
+From: Simon McVittie <smcv at debian.org>
+Date: Fri, 28 Oct 2016 11:37:21 +0100
+Subject: savegames: bounds-check some string lengths to prevent buffer
+ overflow
+
+---
+ code/game/G_Timer.cpp                | 17 ++++++++++++-----
+ code/game/Q3_Interface.cpp           | 15 +++++++++++++++
+ code/game/g_roff.cpp                 |  3 +++
+ code/icarus/IcarusImplementation.cpp | 34 ++++++++++++++++++++++++----------
+ codeJK2/game/Q3_Registers.cpp        | 15 +++++++++++++++
+ codeJK2/game/g_roff.cpp              |  5 +++++
+ 6 files changed, 74 insertions(+), 15 deletions(-)
+
+diff --git a/code/game/G_Timer.cpp b/code/game/G_Timer.cpp
+index d72f525..192594d 100644
+--- a/code/game/G_Timer.cpp
++++ b/code/game/G_Timer.cpp
+@@ -243,12 +243,19 @@ void TIMER_Load( void )
+ 			const char* sg_buffer_data = static_cast<const char*>(
+ 				saved_game.get_buffer_data());
+ 
+-			const int sg_buffer_size = saved_game.get_buffer_size();
++			int sg_buffer_size = saved_game.get_buffer_size();
+ 
+-			std::uninitialized_copy_n(
+-				sg_buffer_data,
+-				sg_buffer_size,
+-				tempBuffer);
++			if (sg_buffer_size < 0 || static_cast<size_t>(sg_buffer_size) >= sizeof(tempBuffer))
++			{
++				sg_buffer_size = 0;
++			}
++			else
++			{
++				std::uninitialized_copy_n(
++					sg_buffer_data,
++					sg_buffer_size,
++					tempBuffer);
++			}
+ 
+ 			tempBuffer[sg_buffer_size] = '\0';
+ 
+diff --git a/code/game/Q3_Interface.cpp b/code/game/Q3_Interface.cpp
+index 56feeeb..2c740d4 100644
+--- a/code/game/Q3_Interface.cpp
++++ b/code/game/Q3_Interface.cpp
+@@ -7326,6 +7326,11 @@ void CQuake3GameInterface::VariableLoadFloats( varFloat_m &fmap )
+ 			INT_ID('F', 'I', 'D', 'L'),
+ 			idSize);
+ 
++		if (idSize < 0 || static_cast<size_t>(idSize) >= sizeof(tempBuffer))
++		{
++			idSize = 0;
++		}
++
+ 		saved_game.read_chunk(
+ 			INT_ID('F', 'I', 'D', 'S'),
+ 			tempBuffer,
+@@ -7371,6 +7376,11 @@ void CQuake3GameInterface::VariableLoadStrings( int type, varString_m &fmap )
+ 			INT_ID('S', 'I', 'D', 'L'),
+ 			idSize);
+ 
++		if (idSize < 0 || static_cast<size_t>(idSize) >= sizeof(tempBuffer))
++		{
++			idSize = 0;
++		}
++
+ 		saved_game.read_chunk(
+ 			INT_ID('S', 'I', 'D', 'S'),
+ 			tempBuffer,
+@@ -7382,6 +7392,11 @@ void CQuake3GameInterface::VariableLoadStrings( int type, varString_m &fmap )
+ 			INT_ID('S', 'V', 'S', 'Z'),
+ 			idSize);
+ 
++		if (idSize < 0 || static_cast<size_t>(idSize) >= sizeof(tempBuffer2))
++		{
++			idSize = 0;
++		}
++
+ 		saved_game.read_chunk(
+ 			INT_ID('S', 'V', 'A', 'L'),
+ 			tempBuffer2,
+diff --git a/code/game/g_roff.cpp b/code/game/g_roff.cpp
+index fe1f79f..9ec25ad 100644
+--- a/code/game/g_roff.cpp
++++ b/code/game/g_roff.cpp
+@@ -703,6 +703,9 @@ void G_LoadCachedRoffs()
+ 			INT_ID('S', 'L', 'E', 'N'),
+ 			len);
+ 
++		if (len < 0 || static_cast<size_t>(len) >= sizeof(buffer))
++			len = 0;
++
+ 		saved_game.read_chunk(
+ 			INT_ID('R', 'S', 'T', 'R'),
+ 			buffer,
+diff --git a/code/icarus/IcarusImplementation.cpp b/code/icarus/IcarusImplementation.cpp
+index 26004b3..7d2fc8f 100644
+--- a/code/icarus/IcarusImplementation.cpp
++++ b/code/icarus/IcarusImplementation.cpp
+@@ -716,12 +716,19 @@ int CIcarus::Load()
+ 	const unsigned char* sg_buffer_data = static_cast<const unsigned char*>(
+ 		saved_game.get_buffer_data());
+ 
+-	const int sg_buffer_size = saved_game.get_buffer_size();
++	int sg_buffer_size = saved_game.get_buffer_size();
+ 
+-	std::uninitialized_copy_n(
+-		sg_buffer_data,
+-		sg_buffer_size,
+-		m_byBuffer);
++	if (sg_buffer_size < 0 || static_cast<size_t>(sg_buffer_size) >= sizeof(m_byBuffer))
++	{
++		sg_buffer_size = 0;
++	}
++	else
++	{
++		std::uninitialized_copy_n(
++			sg_buffer_data,
++			sg_buffer_size,
++			m_byBuffer);
++	}
+ 
+ 	//Load all signals
+ 	if ( LoadSignals() == false )
+@@ -849,12 +856,19 @@ void CIcarus::BufferRead( void *pDstBuff, unsigned long ulNumBytesToRead )
+ 		const unsigned char* sg_buffer_data = static_cast<const unsigned char*>(
+ 			saved_game.get_buffer_data());
+ 
+-		const int sg_buffer_size = saved_game.get_buffer_size();
++		int sg_buffer_size = saved_game.get_buffer_size();
+ 
+-		std::uninitialized_copy_n(
+-			sg_buffer_data,
+-			sg_buffer_size,
+-			m_byBuffer);
++		if (sg_buffer_size < 0 || static_cast<size_t>(sg_buffer_size) >= sizeof(m_byBuffer))
++		{
++			sg_buffer_size = 0;
++		}
++		else
++		{
++			std::uninitialized_copy_n(
++				sg_buffer_data,
++				sg_buffer_size,
++				m_byBuffer);
++		}
+ 
+ 		m_ulBytesRead = 0;	//reset buffer
+ 	}
+diff --git a/codeJK2/game/Q3_Registers.cpp b/codeJK2/game/Q3_Registers.cpp
+index 7797b5f..25c99cd 100644
+--- a/codeJK2/game/Q3_Registers.cpp
++++ b/codeJK2/game/Q3_Registers.cpp
+@@ -408,6 +408,11 @@ void Q3_VariableLoadFloats( varFloat_m &fmap )
+ 			INT_ID('F', 'I', 'D', 'L'),
+ 			idSize);
+ 
++		if (idSize < 0 || static_cast<size_t>(idSize) >= sizeof(tempBuffer))
++		{
++			idSize = 0;
++		}
++
+ 		saved_game.read_chunk(
+ 			INT_ID('F', 'I', 'D', 'S'),
+ 			tempBuffer,
+@@ -453,6 +458,11 @@ void Q3_VariableLoadStrings( int type, varString_m &fmap )
+ 			INT_ID('S', 'I', 'D', 'L'),
+ 			idSize);
+ 
++		if (idSize < 0 || static_cast<size_t>(idSize) >= sizeof(tempBuffer))
++		{
++			idSize = 0;
++		}
++
+ 		saved_game.read_chunk(
+ 			INT_ID('S', 'I', 'D', 'S'),
+ 			tempBuffer,
+@@ -464,6 +474,11 @@ void Q3_VariableLoadStrings( int type, varString_m &fmap )
+ 			INT_ID('S', 'V', 'S', 'Z'),
+ 			idSize);
+ 
++		if (idSize < 0 || static_cast<size_t>(idSize) >= sizeof(tempBuffer2))
++		{
++			idSize = 0;
++		}
++
+ 		saved_game.read_chunk(
+ 			INT_ID('S', 'V', 'A', 'L'),
+ 			tempBuffer2,
+diff --git a/codeJK2/game/g_roff.cpp b/codeJK2/game/g_roff.cpp
+index 7eb1bd1..b5c0240 100644
+--- a/codeJK2/game/g_roff.cpp
++++ b/codeJK2/game/g_roff.cpp
+@@ -678,6 +678,11 @@ void G_LoadCachedRoffs()
+ 			INT_ID('S', 'L', 'E', 'N'),
+ 			len);
+ 
++		if (len < 0 || static_cast<size_t>(len) >= sizeof(buffer))
++		{
++			len = 0;
++		}
++
+ 		saved_game.read_chunk(
+ 			INT_ID('R', 'S', 'T', 'R'),
+ 			buffer,
diff --git a/debian/patches/series b/debian/patches/series
index 37977f5..e29b43e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,6 @@
-Avoid-compiler-warning-when-sscanf-writes-qboolean-throug.patch
 Pick-up-date-from-SOURCE_DATE_EPOCH-for-reproducible-buil.patch
+Consistently-use-static-QINLINE-for-inline-C-code.patch
+Avoid-compiler-warning-when-sscanf-writes-qboolean-throug.patch
+g_svcmds-fix-typo-in-avoiding-non-C-11-compliant-string-s.patch
+savegames-bounds-check-some-string-lengths-to-prevent-buf.patch
 g_utils-disarm-debug-code-that-writes-to-c-nofreeent.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git



More information about the Pkg-games-commits mailing list