Source code of Windows XP (NT5)
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.

129 lines
3.1 KiB

  1. #include "precomp.h"
  2. extern LPWSTR PolicyDNAttributes[];
  3. DWORD
  4. ValidateWirelessPSData(
  5. PWIRELESS_PS_DATA pWirelessPSData,
  6. DWORD dwNetworkType
  7. )
  8. {
  9. DWORD dwError = 0;
  10. DWORD dwSSIDLen = 0;
  11. DWORD dwPSLen = 0;
  12. DWORD dwDescriptionLen = 0;
  13. DWORD dwEAPDataLen = 0;
  14. if (!pWirelessPSData) {
  15. dwError = ERROR_INVALID_PARAMETER;
  16. }
  17. BAIL_ON_WIN32_ERROR(dwError);
  18. if (pWirelessPSData->dwNetworkType != dwNetworkType) {
  19. dwError = ERROR_INVALID_PARAMETER;
  20. }
  21. BAIL_ON_WIN32_ERROR(dwError);
  22. dwSSIDLen = wcslen(pWirelessPSData->pszWirelessSSID);
  23. if (dwSSIDLen == 0) {
  24. dwError = ERROR_INVALID_PARAMETER;
  25. }
  26. BAIL_ON_WIN32_ERROR(dwError);
  27. if (dwSSIDLen < pWirelessPSData->dwWirelessSSIDLen) {
  28. dwError = ERROR_INVALID_PARAMETER;
  29. }
  30. BAIL_ON_WIN32_ERROR(dwError);
  31. if (pWirelessPSData->pszDescription) {
  32. dwDescriptionLen = wcslen(pWirelessPSData->pszDescription);
  33. }
  34. dwEAPDataLen = pWirelessPSData->dwEAPDataLen;
  35. if (dwEAPDataLen) {
  36. if (!(pWirelessPSData->pbEAPData)) {
  37. dwError = ERROR_INVALID_PARAMETER;
  38. }
  39. }
  40. BAIL_ON_WIN32_ERROR(dwError);
  41. dwPSLen = (sizeof(WIRELESS_PS_DATA) - sizeof(DWORD) -sizeof(LPWSTR)) + sizeof(WCHAR) * dwDescriptionLen
  42. - sizeof(LPWSTR) + dwEAPDataLen;
  43. if (dwPSLen != pWirelessPSData->dwPSLen) {
  44. dwError = ERROR_INVALID_PARAMETER;
  45. }
  46. BAIL_ON_WIN32_ERROR(dwError);
  47. error:
  48. return(dwError);
  49. }
  50. DWORD
  51. ValidateWirelessPolicyData(
  52. PWIRELESS_POLICY_DATA pWirelessPolicyData
  53. )
  54. {
  55. PWIRELESS_PS_DATA *ppWirelessPSData = NULL;
  56. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  57. DWORD dwError = 0;
  58. DWORD dwNumPreferredSettings = 0;
  59. DWORD dwNumAPNetworks = 0;
  60. DWORD dwSSIDLen = 0;
  61. DWORD dwPSLen = 0;
  62. DWORD i=0;
  63. if (!pWirelessPolicyData) {
  64. dwError = ERROR_INVALID_PARAMETER;
  65. }
  66. BAIL_ON_WIN32_ERROR(dwError);
  67. if (!pWirelessPolicyData->pszWirelessName) {
  68. dwError = ERROR_INVALID_PARAMETER;
  69. }
  70. BAIL_ON_WIN32_ERROR(dwError);
  71. dwNumPreferredSettings = pWirelessPolicyData->dwNumPreferredSettings;
  72. dwNumAPNetworks = pWirelessPolicyData->dwNumAPNetworks;
  73. if (dwNumPreferredSettings) {
  74. ppWirelessPSData = pWirelessPolicyData->ppWirelessPSData;
  75. if (!ppWirelessPSData) {
  76. dwError = ERROR_INVALID_PARAMETER;
  77. }
  78. BAIL_ON_WIN32_ERROR(dwError);
  79. if (dwNumPreferredSettings < dwNumAPNetworks) {
  80. dwError = ERROR_INVALID_PARAMETER;
  81. }
  82. BAIL_ON_WIN32_ERROR(dwError);
  83. for (i=0; i < dwNumAPNetworks ; ++i) {
  84. pWirelessPSData = ppWirelessPSData[i];
  85. dwError = ValidateWirelessPSData(pWirelessPSData, WIRELESS_NETWORK_TYPE_AP);
  86. BAIL_ON_WIN32_ERROR(dwError);
  87. }
  88. for (i=dwNumAPNetworks; i < dwNumPreferredSettings; ++i) {
  89. pWirelessPSData = ppWirelessPSData[i];
  90. dwError = ValidateWirelessPSData(pWirelessPSData, WIRELESS_NETWORK_TYPE_ADHOC);
  91. BAIL_ON_WIN32_ERROR(dwError);
  92. }
  93. }
  94. error:
  95. return(dwError);
  96. }