From 1cd6a8f272a049cbd21f4ebbbcec081ea67384fd Mon Sep 17 00:00:00 2001 From: Robert Sprowson <rsprowson@gitlab.riscosopen.org> Date: Sun, 25 Mar 2012 09:19:40 +0000 Subject: [PATCH] Tighten up time conversions. Convrsions.s: Don't trash R4 in OS_ConvertDateAndTime Reject buffer sizes > 2G (seems reasonable for a time string, and allows us to claw back a flag bit). PMF/osword.s: Just call Territory_ConvertDateAndTime directly since that's all OS_ConvertDateAndTime does. Trim some now irrelevant comments and switched out code. Version 5.35, 4.79.2.144. Tagged as 'Kernel-5_35-4_79_2_144' --- VersionASM | 10 +++++----- VersionNum | 14 +++++++------- s/Convrsions | 25 ++++++++++++++++--------- s/PMF/osword | 43 +++++++++++++++---------------------------- 4 files changed, 43 insertions(+), 49 deletions(-) diff --git a/VersionASM b/VersionASM index 0b486f4..5edb239 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.143" -Module_Date SETS "24 Mar 2012" -Module_ApplicationDate SETS "24-Mar-12" +Module_MinorVersion SETS "4.79.2.144" +Module_Date SETS "25 Mar 2012" +Module_ApplicationDate SETS "25-Mar-12" Module_ComponentName SETS "Kernel" Module_ComponentPath SETS "castle/RiscOS/Sources/Kernel" -Module_FullVersion SETS "5.35 (4.79.2.143)" -Module_HelpVersion SETS "5.35 (24 Mar 2012) 4.79.2.143" +Module_FullVersion SETS "5.35 (4.79.2.144)" +Module_HelpVersion SETS "5.35 (25 Mar 2012) 4.79.2.144" END diff --git a/VersionNum b/VersionNum index 19e4c19..0e2c615 100644 --- a/VersionNum +++ b/VersionNum @@ -5,19 +5,19 @@ * */ #define Module_MajorVersion_CMHG 5.35 -#define Module_MinorVersion_CMHG 4.79.2.143 -#define Module_Date_CMHG 24 Mar 2012 +#define Module_MinorVersion_CMHG 4.79.2.144 +#define Module_Date_CMHG 25 Mar 2012 #define Module_MajorVersion "5.35" #define Module_Version 535 -#define Module_MinorVersion "4.79.2.143" -#define Module_Date "24 Mar 2012" +#define Module_MinorVersion "4.79.2.144" +#define Module_Date "25 Mar 2012" -#define Module_ApplicationDate "24-Mar-12" +#define Module_ApplicationDate "25-Mar-12" #define Module_ComponentName "Kernel" #define Module_ComponentPath "castle/RiscOS/Sources/Kernel" -#define Module_FullVersion "5.35 (4.79.2.143)" -#define Module_HelpVersion "5.35 (24 Mar 2012) 4.79.2.143" +#define Module_FullVersion "5.35 (4.79.2.144)" +#define Module_HelpVersion "5.35 (25 Mar 2012) 4.79.2.144" #define Module_LibraryVersionInfo "5:35" diff --git a/s/Convrsions b/s/Convrsions index 09ff35a..d0ccfaa 100644 --- a/s/Convrsions +++ b/s/Convrsions @@ -737,13 +737,12 @@ ErrorBlock_BadStation ALIGN ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -; OS_ConvertDateAndTime -; --------------------- +; OS_ConvertStandardDateAndTime +; ----------------------------- ; Convert from 5-byte cs representation to format specified in <SYS$DateFormat> ; In : R0 -> time block ; R1 -> buffer to accept conversion ; R2 = size of buffer -; R3 -> format string ; ; Out : R0 = input value of R1, or error block ; R1 = updated pointer to buffer @@ -751,8 +750,9 @@ ErrorBlock_BadStation ; V Set if error StandardDateTime_Code ROUT - Push "R3,R14" - MOV R3, R2 ; Territory SWI wants things one register up + Push "R3, R14" + MOVS R3, R2 ; Territory SWI wants things one register up + BMI %FT10 ; Actively reject unlikely buffer sizes MOV R2, R1 MOV R1, R0 MOV R0, #-1 ; Use configured territory @@ -774,15 +774,22 @@ StandardDateTime_Code ROUT ; R2 = updated size of buffer ; V Set if error -DateTime_Code ROUT - Push "R4, R14" +DateTime_Code + Push "R3-R4, R14" MOV R4, R3 ; Territory SWI wants things one register up. - MOV R3, R2 + MOVS R3, R2 + BMI %FT10 ; Actively reject unlikely buffer sizes MOV R2, R1 MOV R1, R0 MOV R0, #-1 ; Use configured territory. SWI XTerritory_ConvertDateAndTime - Pull "R4, R14" + Pull "R3-R4, R14" B SLVK_TestV +10 + ADRL R0, ErrorBlock_BuffOverflow + [ International + BL TranslateError + ] + B SLVK_SetV END diff --git a/s/PMF/osword b/s/PMF/osword index 2720dee..a24940a 100644 --- a/s/PMF/osword +++ b/s/PMF/osword @@ -14,8 +14,6 @@ ; ; > $.Source.PMF.osword -maxword * &16 ; highest known osword - ; ***************************************************************************** MACRO @@ -38,8 +36,8 @@ maxword * &16 ; highest known osword OsWord Push "R0-R4, R11, R12, R14" - CMP R0, #(maxword+1) - BLCC OsWordGo ; Call the subsid entry pt. + CMP R0, #(WordTableEnd - WordTableStart) :SHR: 2 + BLLS OsWordGo ; Call the subsid entry pt. LDMIA R13, {R2-R4} ; R2=A, R3=X, R4=Y MOV R1, #Service_UKWord ; osword service reason CLRPSR V_bit, R0 ; in case there's no service @@ -62,11 +60,9 @@ OsWordGo ROUT 10 ; Point to despatch table ADD PC, PC, R0, LSL #2 ; add in the action*4 and go & 0 - ASSERT DespatchWord-%BT10 = 8 - -; ***************************************************************************** + ASSERT WordTableStart - %BT10 = 8 -DespatchWord +WordTableStart BAL OsWord00 BAL OsWord01 @@ -94,6 +90,8 @@ DespatchWord BAL OsWord15 BAL OsWord16 +WordTableEnd + ; ***************************************************************************** ; That's All Folks ; ***************************************************************************** @@ -222,7 +220,7 @@ OsWord07 ROUT MyOsWord ; ***************************************************************************** -; Read the logical colour of a Pixel ( BASIC'S POINT function) +; Read the logical colour of a Pixel ( BASIC's POINT function) ; Uses SWI ReadPoint OsWord09 ROUT @@ -288,10 +286,8 @@ OsWord0D ROUT ; ***************************************************************************** -; Osword 14 (&0E) -- Read Real Time Clock -; Four (was six) different calls - ; Read CMOS clock + OsWord0E ROUT Push "R5-R8, R14" ; R0-R4 saved by Osword @@ -304,11 +300,6 @@ OsWord0E ROUT CMP R0, #3 BCC OsWord0EGamma BEQ OsWord0EDelta - [ {FALSE} - CMP R0, #5 - BCC OsWord0EEpsilon - BEQ OsWord0EZeta ; this is getting ridiculous ! - ] Pull "R5-R8, PC" ; unknown option @@ -322,26 +313,22 @@ OsWord0E ROUT OsWord0EAlpha ROUT -; TMD 30-May-89: We want to enable IRQs here, but OS_ConvertDateAndTime -; loads bytes out of the block, and if IRQs are on it might end using an -; inconsistent value, so we must make a copy of the block on the stack -; and use that. The label OsWord0EDandT was used by a commented out routine -; in file 'RealTime' which will have to be rewritten if it needs to be -; included again. - ADR R0, RealTime ; load snapshot of 5 bytes of real time LDMIA R0, {R0, R2} ; while IRQs are still off Push "R0, R2" ; save on stack CLRPSR I_bit, R0 ; enable IRQs now + OSWord0EReturnString - MOV R0, R13 ; point to stacked copy + MOV R0, #-1 ; This territory + MOV R2, R1 + MOV R1, R13 ; point to stacked copy ; KJB 07-Sep-98: No-one is guaranteeing anywhere the length of %w3 or %m3 - ; see PRM 1-402 and 1-415. So give an indefinite buffer length here (making ; overflow the caller's problem - this call is obsolete anyway). Problem ; first noted with territory Japan, for which %m3 is potentially 5 bytes long. - MOV R2, #&10000000 - ADR R3, TimeFormat - SWI XOS_ConvertDateAndTime + MOV R3, #&10000000 + ADR R4, TimeFormat + SWI XTerritory_ConvertDateAndTime ADD R13, R13, #8 ; junk stack frame MOVVC R0, #13 ; if no error STRVCB R0, [R1] ; overwrite terminating 0 with CR -- GitLab