lib/ruby_smb/dcerpc/ndr.rb in ruby_smb-3.1.4 vs lib/ruby_smb/dcerpc/ndr.rb in ruby_smb-3.1.5

- old
+ new

@@ -310,33 +310,35 @@ attr_accessor :read_until_index, :max_count def initialize_instance @read_until_index = 0 @max_count = 0 + @max_count_set = false super end def insert(index, *objs) obj = super - @max_count = length + @max_count = length unless @max_count_set obj end def slice_index(index) obj = super - @max_count = length + @max_count = length unless @max_count_set obj end def []=(index, value) obj = super - @max_count = length + @max_count = length unless @max_count_set obj end def set_max_count(val) @max_count = @read_until_index = val + @max_count_set = true end end module VarPlugin attr_accessor :read_until_index, :actual_count, :offset @@ -648,11 +650,11 @@ module StructPlugin include ConstructedTypePlugin def should_process_max_count? - # According to the NDR defintion for Structures Containing a Conformant + # According to the NDR definition for Structures Containing a Conformant # Array: # # "In the NDR representation of a structure that contains a # conformant array, the unsigned long integers that give maximum element # counts for dimensions of the array are moved to the beginning of the @@ -759,26 +761,26 @@ if obj.is_a?(PointerPlugin) # Pointers are always 4-bytes aligned return (4 - (rel_offset % 4)) % 4 end if obj.is_a?(ConfPlugin) - # `max_count` should have been handled at the begining of the structure + # `max_count` should have been handled at the beginning of the structure # already. We need to fix `rel_offset` since it includes the # `max_count` 4 bytes, plus the possible padding bytes needed to align # the structure. This is required because BinData Struct is not - # aware of `max_count` and considere the first field to be the begining + # aware of `max_count` and consider the first field to be the beginning # of the structure instead. We have to make sure the alignment is - # calculated from the begining of the structure. + # calculated from the beginning of the structure. align = eval_parameter(:byte_align) pad_length = (align - (4 % align)) % align rel_offset += (4 + pad_length) # We need to handle another corner case, which is a Conformant array # (not Varying). The size information (max_count) has been place in # from of the structure and no other size information is present before # the actual elements of the array. Therefore, the alignment must be - # done accroding to th rules of the elements. Since a NdrArray has its + # done according to the rules of the elements. Since a NdrArray has its # default :byte_align value set to 4 (:max_count size), we have to make # sure the element size is used instead. unless obj.is_a?(VarPlugin) return obj.align_element_size(rel_offset) end @@ -836,10 +838,14 @@ super extend StructPlugin end end + # + # [Unions](https://pubs.opengroup.org/onlinepubs/9629399/chap14.htm#tagcjh_19_03_08) + # + # TODO: Unions # TODO: Pipes # # [Pointers](https://pubs.opengroup.org/onlinepubs/9629399/chap14.htm#tagcjh_19_03_10) @@ -1202,9 +1208,14 @@ extend PointerClassPlugin end class NdrByteArrayPtr < NdrConfVarArray default_parameters type: :ndr_uint8 + extend PointerClassPlugin + end + + class NdrUint16ArrayPtr < NdrConfVarArray + default_parameters type: :ndr_uint16 extend PointerClassPlugin end class NdrFileTimePtr < NdrFileTime extend PointerClassPlugin