Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.2 KiB

  1. '***************************************************************************
  2. 'This script tests array out-of-bounds conditions on properties and
  3. 'qualifiers
  4. '***************************************************************************
  5. On Error Resume Next
  6. while true
  7. Set Service = GetObject("winmgmts:root/default")
  8. Set Class = Service.Get()
  9. Class.Path_.Class = "ARRAYPROP00"
  10. Set Property = Class.Properties_.Add ("p1", 19, true)
  11. Property.Value = Array (12, 787, 34124)
  12. Set Qualifier = Property.Qualifiers_.Add("wibble", Array ("fred", "the", "hamster"))
  13. '************************************************************
  14. ' PROPERTY
  15. '************************************************************
  16. 'Out-of-bounds read
  17. WScript.Echo Class.Properties_("p1")(3)
  18. if Err <> 0 Then
  19. WScript.Echo "As expected got read OOB:", Err.Description
  20. Err.Clear
  21. End if
  22. 'Out-of-bounds write ; should expand the array
  23. Class.Properties_("p1")(3) = 783837
  24. if Err <> 0 Then
  25. WScript.Echo "ERROR:", Err.Description
  26. Err.Clear
  27. End if
  28. 'Now read should be in bounds
  29. WScript.Echo "Value of ARRAYPROP00.Class.p1(3) is [783837]:", Class.Properties_("p1")(3)
  30. 'Out-of-bounds write ; should expand the array
  31. Class.p1(4) = 783844
  32. if Err <> 0 Then
  33. WScript.Echo "ERROR:", Err.Description
  34. Err.Clear
  35. End if
  36. 'Now read should be in bounds
  37. WScript.Echo "Value of ARRAYPROP00.Class.p1(4) is [783844]:", Class.p1(4)
  38. if Err <> 0 Then
  39. WScript.Echo "ERROR:", Err.Description
  40. Err.Clear
  41. End if
  42. '************************************************************
  43. ' QUALIFIER
  44. '************************************************************
  45. 'Out-of-bounds read
  46. WScript.Echo Property.Qualifiers_("wibble")(3)
  47. if Err <> 0 Then
  48. WScript.Echo "As expected got read OOB:", Err.Description
  49. Err.Clear
  50. End if
  51. 'Out-of-bounds write ; should expand the array
  52. Property.Qualifiers_("wibble")(3) = "jam"
  53. if Err <> 0 Then
  54. WScript.Echo "ERROR:", Err.Description
  55. Err.Clear
  56. End if
  57. 'Now read should be in bounds
  58. WScript.Echo "Value of qualifier(3) is [jam]:", Property.Qualifiers_("wibble")(3)
  59. if Err <> 0 Then
  60. WScript.Echo "ERROR:", Err.Description
  61. Err.Clear
  62. End if
  63. wend