Ticket #250: libbasic_fix_1_of_1_rev_ecd8104acb9a_Issue__250_User_input_checks___raise_an_error_when_the_method_parameter_does_not_fit_the_requirements.patch

File libbasic_fix_1_of_1_rev_ecd8104acb9a_Issue__250_User_input_checks___raise_an_error_when_the_method_parameter_does_not_fit_the_requirements.patch, 3.0 KB (added by patrik.svestka@…, 5 years ago)
  • Win32OperatingSystem.st

    # HG changeset patch
    # User Patrik Svestka <patrik.svestka@gmail.com>
    # Date 1548940254 -3600
    #      Thu Jan 31 14:10:54 2019 +0100
    # Branch jv
    # Node ID ecd8104acb9a1a1355128660fc8ee8d5d6677c3f
    # Parent  26642c0820c97a36c9714ffe6161b88e4eac8c43
    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
    
    diff -r 26642c0820c9 -r ecd8104acb9a Win32OperatingSystem.st
    a b  
    1621816218    "
    1621916219!
    1622016220
    16221 remoteKeyOnHost:hostName
     16221remoteKeyOnHost:hostNameString
    1622216222    "return the corresponding registry entry from
    1622316223     a remote computers registry.
    1622416224     Note: The registry key must be form a predefined list defined by Microsoft."
    1622516225
    1622616226    |hostNameUtf16Z newEntry remoteHandle errorNumber|
    16227 
    16228     hostNameUtf16Z := hostName notEmptyOrNil ifTrue:[hostName asUnicode16StringZ].
     16227   
     16228    "/ checking user input
     16229    hostNameString isString ifFalse:[
     16230        self error: 'hostNameString is not a string!!'
     16231    ].
     16232    hostNameUtf16Z := hostNameString notEmptyOrNil ifTrue:[hostNameString asUnicode16StringZ].
    1622916233   
    1623016234%{
    1623116235    HKEY myKey, remoteKey = 0;
     
    1630916313
    1631016314    |subKeyName errorNumber|
    1631116315
     16316    "/ checking user input
     16317    subKeyIndex isInteger ifFalse:[
     16318        self error: 'subKeyIndex is not an integer!!'
     16319    ].
     16320
    1631216321%{
    1631316322   /* dwIndex (subKeyIndex)
    1631416323    * The index of the subkey to retrieve. This parameter should be zero for the first call to the RegEnumKeyEx function and then
     
    1639816407     WARNING: subKeyIndex is 0-based!!"
    1639916408
    1640016409    |subKeyName subKeyClassName errorNumber|
     16410   
     16411    "/ checking user input
     16412    subKeyIndex isInteger ifFalse:[
     16413        self error: 'subKeyIndex is not an integer!!'
     16414    ].
    1640116415
    1640216416%{
    1640316417   /* dwIndex (subKeyIndex)
     
    1670516719
    1670616720    |valueName errorNumber|
    1670716721
     16722    "/ checking user input
     16723    valueIndex isInteger ifFalse:[
     16724        self error: 'valueIndex is not an integer!!'
     16725    ].
     16726
    1670816727%{
    1670916728   /* dwIndex (valueIndex)
    1671016729    * The index of the value to be retrieved. This parameter should be zero for the first call to the RegEnumValue function and then be
     
    1679116810
    1679216811    |nameUtf16Z stringArray retVal errorNumber|
    1679316812
     16813    "/ checking user input
     16814    nameString isString ifFalse:[
     16815        self error: 'nameString is not a string!!'
     16816    ].
     16817
    1679416818    "/ adding terminating null into empty string
    1679516819    nameString notNil ifTrue:[
    1679616820        nameString isEmpty ifTrue:[nameUtf16Z := (nameString, (Character codePoint: 0)) asUnicode16String] "/ needed for defaultValue