Issue #250 User input checks - raise an error when the method parameter does not fit the requirements jv
authorPatrik Svestka <patrik.svestka@gmail.com>
Thu, 31 Jan 2019 14:10:54 +0100
branchjv
changeset 23765 ecd8104acb9a
parent 23764 26642c0820c9
child 23766 14192e6eeae8
Issue #250 User input checks - raise an error when the method parameter does not fit the requirements - remoteKeyOnHost: changing hostName to hostNameString and added a hostNameString string check - subKeyAtIndex: added user input check if the subKeyIndex is an integer, if not raise an error - subKeyNameAndClassAtIndex: added user input check if the subKeyIndex is an integer, if not raise an error - valueNameAtIndex: added user input check if the valueIndex is an integer, if not raise an error - valueNamed: nameSring is not a string raise an error
Win32OperatingSystem.st
--- a/Win32OperatingSystem.st	Wed Dec 12 14:40:27 2018 +0100
+++ b/Win32OperatingSystem.st	Thu Jan 31 14:10:54 2019 +0100
@@ -16218,14 +16218,18 @@
     "
 !
 
-remoteKeyOnHost:hostName
+remoteKeyOnHost:hostNameString
     "return the corresponding registry entry from
      a remote computers registry.
      Note: The registry key must be form a predefined list defined by Microsoft."
 
     |hostNameUtf16Z newEntry remoteHandle errorNumber|
-
-    hostNameUtf16Z := hostName notEmptyOrNil ifTrue:[hostName asUnicode16StringZ].
+    
+    "/ checking user input
+    hostNameString isString ifFalse:[
+        self error: 'hostNameString is not a string!!'
+    ].
+    hostNameUtf16Z := hostNameString notEmptyOrNil ifTrue:[hostNameString asUnicode16StringZ].
     
 %{
     HKEY myKey, remoteKey = 0;
@@ -16309,6 +16313,11 @@
 
     |subKeyName errorNumber|
 
+    "/ checking user input
+    subKeyIndex isInteger ifFalse:[
+        self error: 'subKeyIndex is not an integer!!'
+    ].
+
 %{
    /* dwIndex (subKeyIndex)
     * The index of the subkey to retrieve. This parameter should be zero for the first call to the RegEnumKeyEx function and then 
@@ -16398,6 +16407,11 @@
      WARNING: subKeyIndex is 0-based!!"
 
     |subKeyName subKeyClassName errorNumber|
+    
+    "/ checking user input
+    subKeyIndex isInteger ifFalse:[
+        self error: 'subKeyIndex is not an integer!!'
+    ].
 
 %{
    /* dwIndex (subKeyIndex)
@@ -16705,6 +16719,11 @@
 
     |valueName errorNumber|
 
+    "/ checking user input
+    valueIndex isInteger ifFalse:[
+        self error: 'valueIndex is not an integer!!'
+    ].
+
 %{
    /* dwIndex (valueIndex)
     * The index of the value to be retrieved. This parameter should be zero for the first call to the RegEnumValue function and then be 
@@ -16791,6 +16810,11 @@
 
     |nameUtf16Z stringArray retVal errorNumber|
 
+    "/ checking user input
+    nameString isString ifFalse:[
+        self error: 'nameString is not a string!!'
+    ].
+
     "/ adding terminating null into empty string
     nameString notNil ifTrue:[
         nameString isEmpty ifTrue:[nameUtf16Z := (nameString, (Character codePoint: 0)) asUnicode16String] "/ needed for defaultValue