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.

82 lines
2.1 KiB

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