Commit 97f47c50 authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

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'
parent 939fa0cf
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
GBLS Module_ComponentPath GBLS Module_ComponentPath
Module_MajorVersion SETS "5.35" Module_MajorVersion SETS "5.35"
Module_Version SETA 535 Module_Version SETA 535
Module_MinorVersion SETS "4.79.2.134" Module_MinorVersion SETS "4.79.2.135"
Module_Date SETS "27 Jan 2012" Module_Date SETS "31 Jan 2012"
Module_ApplicationDate SETS "27-Jan-12" Module_ApplicationDate SETS "31-Jan-12"
Module_ComponentName SETS "Kernel" Module_ComponentName SETS "Kernel"
Module_ComponentPath SETS "castle/RiscOS/Sources/Kernel" Module_ComponentPath SETS "castle/RiscOS/Sources/Kernel"
Module_FullVersion SETS "5.35 (4.79.2.134)" Module_FullVersion SETS "5.35 (4.79.2.135)"
Module_HelpVersion SETS "5.35 (27 Jan 2012) 4.79.2.134" Module_HelpVersion SETS "5.35 (31 Jan 2012) 4.79.2.135"
END END
...@@ -5,19 +5,19 @@ ...@@ -5,19 +5,19 @@
* *
*/ */
#define Module_MajorVersion_CMHG 5.35 #define Module_MajorVersion_CMHG 5.35
#define Module_MinorVersion_CMHG 4.79.2.134 #define Module_MinorVersion_CMHG 4.79.2.135
#define Module_Date_CMHG 27 Jan 2012 #define Module_Date_CMHG 31 Jan 2012
#define Module_MajorVersion "5.35" #define Module_MajorVersion "5.35"
#define Module_Version 535 #define Module_Version 535
#define Module_MinorVersion "4.79.2.134" #define Module_MinorVersion "4.79.2.135"
#define Module_Date "27 Jan 2012" #define Module_Date "31 Jan 2012"
#define Module_ApplicationDate "27-Jan-12" #define Module_ApplicationDate "31-Jan-12"
#define Module_ComponentName "Kernel" #define Module_ComponentName "Kernel"
#define Module_ComponentPath "castle/RiscOS/Sources/Kernel" #define Module_ComponentPath "castle/RiscOS/Sources/Kernel"
#define Module_FullVersion "5.35 (4.79.2.134)" #define Module_FullVersion "5.35 (4.79.2.135)"
#define Module_HelpVersion "5.35 (27 Jan 2012) 4.79.2.134" #define Module_HelpVersion "5.35 (31 Jan 2012) 4.79.2.135"
#define Module_LibraryVersionInfo "5:35" #define Module_LibraryVersionInfo "5:35"
...@@ -815,12 +815,13 @@ schl_nofudgesofar ...@@ -815,12 +815,13 @@ schl_nofudgesofar
CMP R4, #4 CMP R4, #4
BLS schl_fudgeloop BLS schl_fudgeloop
schl_nofudge schl_nofudge
AND R4, R1,#Oscli_CHashValMask ;hash value, masked for command hashing
ADRL R1, SysCommsModule
ADRL R2, SysCoHashedCmdTab 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 LDR R2, [R2, R4, LSL #2] ;command list for this hash value
SEC ;carry set means sys module ADRL R1, SysCommsModule
B ModCommsLookUp_AltEntry 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 schl_fudge
ADRL R1, SysCommsModule ADRL R1, SysCommsModule
ADRL R2, SHC_fudgeulike ADRL R2, SHC_fudgeulike
...@@ -835,12 +836,13 @@ schl_fudge ...@@ -835,12 +836,13 @@ schl_fudge
UtilCommsHashedLookup ROUT UtilCommsHashedLookup ROUT
Push "R0, R2-R10, lr" Push "R0, R2-R10, lr"
AND R4, R1,#Oscli_CHashValMask ;hash value, masked for command hashing
ADRL R1, UtilityMod
ADRL R2, UtilHashedCmdTab 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 LDR R2, [R2, R4, LSL #2] ;command list for this hash value
CLC ADRL R1, UtilityMod
B ModCommsLookUp_AltEntry 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 ] ;Oscli_HashedCommands
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment