Commit 25b0870e authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Make SpriteExtend perform sanity checks on sprite/area pointers

Detail:
  Sources/SprExtend - Added new CheckAlignedAndSensible macro to make it easy to check pointers. Pointers which aren't word aligned or are less than 256 are considered bad.
  Sources/SprOp - Update findsprite, getspritename and getspriteaddr to check sprite/area/name pointers for validity. Sprite names are the only ones that are allowed to not be word aligned.
Admin:
  Tested on rev A2 BB-xM.


Version 1.43. Tagged as 'SprExtend-1_43'
parent 1a702ba7
...@@ -257,6 +257,15 @@ $l LDR $temp, [$sprite, #$offset] ...@@ -257,6 +257,15 @@ $l LDR $temp, [$sprite, #$offset]
BHI %F99 ; out of range BHI %F99 ; out of range
MEND MEND
MACRO
$l CheckAlignedAndSensible $addr,$failed
$l TST $addr, #3 ; word aligned?
BNE $failed
CMP $addr, #256 ; outside processor vectors?
BLO $failed
MEND
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Data areas & register allocation ; Data areas & register allocation
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
......
...@@ -1042,6 +1042,12 @@ getspritename ...@@ -1042,6 +1042,12 @@ getspritename
ADRL R3,spritename ADRL R3,spritename
ADD R4,R3,#12 ADD R4,R3,#12
CMP R2,#256 ; sensible name ptr?
BHS %FT01
ADR R0,ErrorBlock_BadAddress
BL copy_error_one
B %FT99
01 01
LDRB R0,[R2],#1 LDRB R0,[R2],#1
CMP R0,#" " ; ignore control characters and <space> too! CMP R0,#" " ; ignore control characters and <space> too!
...@@ -1076,14 +1082,17 @@ getspriteaddr ...@@ -1076,14 +1082,17 @@ getspriteaddr
ADREQ R0, ErrorBlock_NoWorkSpace ; can't do anything with this! ADREQ R0, ErrorBlock_NoWorkSpace ; can't do anything with this!
addr r1, Title, EQ addr r1, Title, EQ
BLEQ copy_error_one ; Always sets the V bit BLEQ copy_error_one ; Always sets the V bit
BVS %FT99 BVS %FT98
MOV R1,R0 ; R1 -> system sprite area MOV R1,R0 ; R1 -> system sprite area
STR R1,[sp] ; return for AppendSprite STR R1,[sp] ; return for AppendSprite
B %FT01
00 00
CheckAlignedAndSensible R1,%F99
TEQ R14,#&200 ; R2 --> sprite already TEQ R14,#&200 ; R2 --> sprite already
BEQ %FT99 BEQ %FT97
01
ADRL R14,spritename ADRL R14,spritename
LDMIA R14,{R3,R4,R5} LDMIA R14,{R3,R4,R5}
...@@ -1101,7 +1110,7 @@ getspriteaddr ...@@ -1101,7 +1110,7 @@ getspriteaddr
] ]
BLCS get_sprite_doesnt_exist_error ; r0-> error block, V set BLCS get_sprite_doesnt_exist_error ; r0-> error block, V set
BVS %FT99 BVS %FT98
LDMIA R2,{R1,R6,R7,R8} ; get link plus name LDMIA R2,{R1,R6,R7,R8} ; get link plus name
TEQ R6,R3 TEQ R6,R3
...@@ -1109,9 +1118,17 @@ getspriteaddr ...@@ -1109,9 +1118,17 @@ getspriteaddr
TEQEQ R8,R5 TEQEQ R8,R5
ADDNE R2,R2,R1 ADDNE R2,R2,R1
BNE %BT04 BNE %BT04
97
CheckAlignedAndSensible R2,%F99
98
Pull "R1,R3-R9,PC"
99 99
ADR R0,ErrorBlock_BadAddress
BL copy_error_one
Pull "R1,R3-R9,PC" Pull "R1,R3-R9,PC"
MakeErrorBlock BadAddress
; makepalette16bpp ; makepalette16bpp
; convert palette to 16bpp for output to 16bpp mode plotting directly from palette ; convert palette to 16bpp for output to 16bpp mode plotting directly from palette
; if this is not done, the spriteextend blitter will run out of registers! ; if this is not done, the spriteextend blitter will run out of registers!
...@@ -2889,8 +2906,7 @@ Go_CheckSpriteArea ...@@ -2889,8 +2906,7 @@ Go_CheckSpriteArea
Push "r1-r5, lr" ; 6 regs + r0/r10/r11 to mess with, total 9 Push "r1-r5, lr" ; 6 regs + r0/r10/r11 to mess with, total 9
TST r1, #3 ; at least need an aligned area to start with CheckAlignedAndSensible r1,%F99 ; at least need an aligned area to start with
BNE %FT99
ASSERT SpriteAreaCBsize = (4 * 4) ASSERT SpriteAreaCBsize = (4 * 4)
LDMIA r1, {r2-r5} LDMIA r1, {r2-r5}
......
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
GBLS Module_HelpVersion GBLS Module_HelpVersion
GBLS Module_ComponentName GBLS Module_ComponentName
GBLS Module_ComponentPath GBLS Module_ComponentPath
Module_MajorVersion SETS "1.42" Module_MajorVersion SETS "1.43"
Module_Version SETA 142 Module_Version SETA 143
Module_MinorVersion SETS "" Module_MinorVersion SETS ""
Module_Date SETS "14 Apr 2011" Module_Date SETS "25 Jun 2011"
Module_ApplicationDate SETS "14-Apr-11" Module_ApplicationDate SETS "25-Jun-11"
Module_ComponentName SETS "SprExtend" Module_ComponentName SETS "SprExtend"
Module_ComponentPath SETS "mixed/RiscOS/Sources/Video/Render/SprExtend" Module_ComponentPath SETS "mixed/RiscOS/Sources/Video/Render/SprExtend"
Module_FullVersion SETS "1.42" Module_FullVersion SETS "1.43"
Module_HelpVersion SETS "1.42 (14 Apr 2011)" Module_HelpVersion SETS "1.43 (25 Jun 2011)"
END END
/* (1.42) /* (1.43)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1. * Last processed by srccommit version: 1.1.
* *
*/ */
#define Module_MajorVersion_CMHG 1.42 #define Module_MajorVersion_CMHG 1.43
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 14 Apr 2011 #define Module_Date_CMHG 25 Jun 2011
#define Module_MajorVersion "1.42" #define Module_MajorVersion "1.43"
#define Module_Version 142 #define Module_Version 143
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "14 Apr 2011" #define Module_Date "25 Jun 2011"
#define Module_ApplicationDate "14-Apr-11" #define Module_ApplicationDate "25-Jun-11"
#define Module_ComponentName "SprExtend" #define Module_ComponentName "SprExtend"
#define Module_ComponentPath "mixed/RiscOS/Sources/Video/Render/SprExtend" #define Module_ComponentPath "mixed/RiscOS/Sources/Video/Render/SprExtend"
#define Module_FullVersion "1.42" #define Module_FullVersion "1.43"
#define Module_HelpVersion "1.42 (14 Apr 2011)" #define Module_HelpVersion "1.43 (25 Jun 2011)"
#define Module_LibraryVersionInfo "1:42" #define Module_LibraryVersionInfo "1:43"
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