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.

170 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1991-1992 Microsoft Corporation
  3. Module Name:
  4. ValidSmb.c
  5. Abstract:
  6. This module contains RapIsValidDescriptorSmb, which tests a descriptor to
  7. make sure it is a valid descriptor which can be placed in an SMB..
  8. Author:
  9. John Rogers (JohnRo) 17-Apr-1991
  10. Environment:
  11. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  12. Requires ANSI C extensions: slash-slash comments, long external names.
  13. Revision History:
  14. 17-Apr-1991 JohnRo
  15. Created.
  16. 03-Jun-1991 JohnRo
  17. PC-LINT found a bug.
  18. 19-Aug-1991 JohnRo
  19. Allow UNICODE use.
  20. Avoid FORMAT_POINTER equate (nonportable).
  21. 16-Aug-1992 JohnRo
  22. RAID 2920: Support UTC timezone in net code.
  23. Use PREFIX_ equates.
  24. --*/
  25. // These must be included first:
  26. #include <windef.h> // IN, LPDWORD, NULL, OPTIONAL, DWORD, etc.
  27. #include <lmcons.h> // NET_API_STATUS
  28. // These may be included in any order:
  29. #include <netdebug.h> // NetpBreakPoint(), NetpKdPrint(()).
  30. #include <prefix.h> // PREFIX_ equates.
  31. #include <rap.h> // My prototype, LPDESC, DESC_CHAR_IS_DIGIT().
  32. #include <remtypes.h> // REM_WORD, etc.
  33. BOOL
  34. RapIsValidDescriptorSmb (
  35. IN LPDESC Desc
  36. )
  37. /*++
  38. Routine Description:
  39. RapIsValidDescriptorSmb checks a given descriptor to make sure it is
  40. valid for sending to a 16-bit downlevel machine in an SMB.
  41. Arguments:
  42. Desc - the alleged descriptor string. Note that a null pointer is
  43. invalid, but a pointer to a null string is OK.
  44. Return Value:
  45. BOOL - TRUE if valid, FALSE otherwise.
  46. --*/
  47. {
  48. if (Desc == NULL) {
  49. return (FALSE);
  50. }
  51. if (*Desc == '\0') {
  52. return (TRUE);
  53. }
  54. //
  55. // Loop through the input descriptor string.
  56. //
  57. while ( *Desc != '\0' ) {
  58. switch ( *Desc++ ) {
  59. ///////////////////////////////////////
  60. // Items which allow trailing digits //
  61. ///////////////////////////////////////
  62. case REM_BYTE:
  63. case REM_WORD:
  64. case REM_DWORD:
  65. case REM_BYTE_PTR:
  66. case REM_WORD_PTR:
  67. case REM_DWORD_PTR:
  68. case REM_RCV_BYTE_PTR:
  69. case REM_RCV_WORD_PTR:
  70. case REM_RCV_DWORD_PTR:
  71. case REM_FILL_BYTES:
  72. // Skip digits...
  73. while (DESC_CHAR_IS_DIGIT(*Desc)) {
  74. Desc++;
  75. }
  76. break;
  77. /////////////////////////////////////////////
  78. // Items which don't allow trailing digits //
  79. /////////////////////////////////////////////
  80. case REM_ASCIZ: // Strings with trailing digits are internal use only.
  81. case REM_NULL_PTR:
  82. case REM_SEND_BUF_PTR:
  83. case REM_SEND_BUF_LEN:
  84. case REM_SEND_LENBUF:
  85. case REM_DATE_TIME:
  86. case REM_RCV_BUF_PTR:
  87. case REM_RCV_BUF_LEN:
  88. case REM_PARMNUM:
  89. case REM_ENTRIES_READ:
  90. case REM_AUX_NUM:
  91. case REM_AUX_NUM_DWORD:
  92. case REM_DATA_BLOCK:
  93. if (DESC_CHAR_IS_DIGIT( *Desc )) {
  94. NetpKdPrint(( PREFIX_NETRAP
  95. "RapIsValidDescriptorSmb: "
  96. "Unsupported digit(s) at " FORMAT_LPVOID
  97. ": for " FORMAT_LPDESC_CHAR "\n",
  98. (LPVOID) (Desc-1), *(Desc-1) ));
  99. NetpBreakPoint();
  100. return (FALSE);
  101. }
  102. break;
  103. ///////////////////////////////////////
  104. // Items which are internal use only //
  105. ///////////////////////////////////////
  106. case REM_SIGNED_DWORD:
  107. case REM_SIGNED_DWORD_PTR:
  108. case REM_ASCIZ_TRUNCATABLE:
  109. case REM_IGNORE:
  110. case REM_WORD_LINEAR:
  111. case REM_UNSUPPORTED_FIELD:
  112. case REM_EPOCH_TIME_GMT: /*FALLTHROUGH*/
  113. case REM_EPOCH_TIME_LOCAL:
  114. // Internal only!
  115. NetpKdPrint(( PREFIX_NETRAP
  116. "RapIsValidDescriptorSmb: Internal use only desc"
  117. " at " FORMAT_LPVOID ": " FORMAT_LPDESC_CHAR "\n",
  118. (LPVOID) (Desc-1), *(Desc-1) ));
  119. NetpBreakPoint();
  120. return (FALSE);
  121. default:
  122. NetpKdPrint(( PREFIX_NETRAP
  123. "RapIsValidDescriptorSmb: Unsupported input character"
  124. " at " FORMAT_LPVOID ": " FORMAT_LPDESC_CHAR "\n",
  125. (LPVOID) (Desc-1), *(Desc-1) ));
  126. NetpBreakPoint();
  127. return (FALSE);
  128. }
  129. }
  130. return (TRUE); // All OK.
  131. } // RapIsValidDescriptorSmb