From 97f47c504c7858ab592ff9a99b3f600b21af0db5 Mon Sep 17 00:00:00 2001 From: Jeffrey Lee <jlee@gitlab.riscosopen.org> Date: Wed, 1 Feb 2012 00:03:16 +0000 Subject: [PATCH] Add null hash table entry checks to SysCommsModule & UtilityModule hash table lookup Detail: s/Oscli - In SysCommsHashedLookup and UtilCommsHashedLookup, check for null hash table entries instead of just blindly calling ModCommsLookUp_AltEntry. This fixes an issue where a crash will occur iff: (a) You enter a command which has no entry in one of the two hash tables (b) The command is a valid command (with a code entry point) if you reinterpret the corresponding module header as a command table In reality, for recent versions of RISC OS 5, you'll get a crash only when trying to execute the command 's'. Some previous OS versions (e.g. 5.12) appear to have been immune to the crash. If (a) was true but (b) was false the bug would have also resulted in a small performance hit caused by attempting to scan the module headers for matching commands. Admin: Tested in Tungsten & OMAP ROM builds 's' no longer crashes, and commands included in the two hash tables still seem to function as normal. Fixes issue reported on forums: http://www.riscosopen.org/forum/forums/4/topics/902 Version 5.35, 4.79.2.135. Tagged as 'Kernel-5_35-4_79_2_135' --- VersionASM | 10 +++++----- VersionNum | 14 +++++++------- s/Oscli | 18 ++++++++++-------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/VersionASM b/VersionASM index d5e8c23..4b434a6 100644 --- a/VersionASM +++ b/VersionASM @@ -13,11 +13,11 @@ GBLS Module_ComponentPath Module_MajorVersion SETS "5.35" Module_Version SETA 535 -Module_MinorVersion SETS "4.79.2.134" -Module_Date SETS "27 Jan 2012" -Module_ApplicationDate SETS "27-Jan-12" +Module_MinorVersion SETS "4.79.2.135" +Module_Date SETS "31 Jan 2012" +Module_ApplicationDate SETS "31-Jan-12" Module_ComponentName SETS "Kernel" Module_ComponentPath SETS "castle/RiscOS/Sources/Kernel" -Module_FullVersion SETS "5.35 (4.79.2.134)" -Module_HelpVersion SETS "5.35 (27 Jan 2012) 4.79.2.134" +Module_FullVersion SETS "5.35 (4.79.2.135)" +Module_HelpVersion SETS "5.35 (31 Jan 2012) 4.79.2.135" END diff --git a/VersionNum b/VersionNum index ec3bdf2..ab41b5c 100644 --- a/VersionNum +++ b/VersionNum @@ -5,19 +5,19 @@ * */ #define Module_MajorVersion_CMHG 5.35 -#define Module_MinorVersion_CMHG 4.79.2.134 -#define Module_Date_CMHG 27 Jan 2012 +#define Module_MinorVersion_CMHG 4.79.2.135 +#define Module_Date_CMHG 31 Jan 2012 #define Module_MajorVersion "5.35" #define Module_Version 535 -#define Module_MinorVersion "4.79.2.134" -#define Module_Date "27 Jan 2012" +#define Module_MinorVersion "4.79.2.135" +#define Module_Date "31 Jan 2012" -#define Module_ApplicationDate "27-Jan-12" +#define Module_ApplicationDate "31-Jan-12" #define Module_ComponentName "Kernel" #define Module_ComponentPath "castle/RiscOS/Sources/Kernel" -#define Module_FullVersion "5.35 (4.79.2.134)" -#define Module_HelpVersion "5.35 (27 Jan 2012) 4.79.2.134" +#define Module_FullVersion "5.35 (4.79.2.135)" +#define Module_HelpVersion "5.35 (31 Jan 2012) 4.79.2.135" #define Module_LibraryVersionInfo "5:35" diff --git a/s/Oscli b/s/Oscli index 2f6473c..38d6d97 100644 --- a/s/Oscli +++ b/s/Oscli @@ -815,12 +815,13 @@ schl_nofudgesofar CMP R4, #4 BLS schl_fudgeloop schl_nofudge - AND R4, R1,#Oscli_CHashValMask ;hash value, masked for command hashing - ADRL R1, SysCommsModule ADRL R2, SysCoHashedCmdTab + AND R4, R1,#Oscli_CHashValMask ;hash value, masked for command hashing LDR R2, [R2, R4, LSL #2] ;command list for this hash value - SEC ;carry set means sys module - B ModCommsLookUp_AltEntry + ADRL R1, SysCommsModule + CMP R2, #1 ;set carry if valid table entry + BCS ModCommsLookUp_AltEntry ;note: carry set to indicate sys module + Pull "R0, R2-R10, pc" ;bail if null hash table entry (with carry clear to indicate failure) schl_fudge ADRL R1, SysCommsModule ADRL R2, SHC_fudgeulike @@ -835,12 +836,13 @@ schl_fudge UtilCommsHashedLookup ROUT Push "R0, R2-R10, lr" - AND R4, R1,#Oscli_CHashValMask ;hash value, masked for command hashing - ADRL R1, UtilityMod ADRL R2, UtilHashedCmdTab + AND R4, R1,#Oscli_CHashValMask ;hash value, masked for command hashing LDR R2, [R2, R4, LSL #2] ;command list for this hash value - CLC - B ModCommsLookUp_AltEntry + ADRL R1, UtilityMod + TEQ R2, #0,2 ;check R2 and clear carry + BNE ModCommsLookUp_AltEntry + Pull "R0, R2-R10, pc" ;bail if null hash table entry ; ] ;Oscli_HashedCommands -- GitLab