Skip to content

Commit fcee4db

Browse files
committed
Reorder the buffer fields to match windows
1 parent 48c4ce5 commit fcee4db

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/rex/proto/ms_dtyp.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -831,12 +831,14 @@ def group_sid=(sid)
831831

832832
private
833833

834+
BUFFER_FIELD_ORDER = %i[ sacl dacl owner_sid group_sid ]
835+
834836
def build_buffer
835837
buf = ''
836-
buf << owner_sid.to_binary_s if owner_sid
837-
buf << group_sid.to_binary_s if group_sid
838-
buf << sacl.to_binary_s if sacl
839-
buf << dacl.to_binary_s if dacl
838+
BUFFER_FIELD_ORDER.each do |field_name|
839+
field_value = send(field_name)
840+
buf << field_value.to_binary_s if field_value
841+
end
840842
buf
841843
end
842844

@@ -850,7 +852,7 @@ def offset_for(field)
850852
return 0 unless instance_variable_get("@#{field}")
851853

852854
offset = buffer.rel_offset
853-
%i[ owner_sid group_sid sacl dacl ].each do |cursor|
855+
BUFFER_FIELD_ORDER.each do |cursor|
854856
break if cursor == field
855857

856858
cursor = instance_variable_get("@#{cursor}")

0 commit comments

Comments
 (0)