Skip to content

Commit 0ea20fc

Browse files
committed
fix: null-terminated string attribute inheritance
1 parent ab84d04 commit 0ea20fc

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

midl/types.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ type Field struct {
179179
}
180180

181181
func (f *Field) IsString() bool {
182-
return f.Attrs.Usage.IsString || (f.Type.Attrs != nil && f.Type.Attrs.Usage.IsString)
182+
return f.Attrs.Usage.IsString || f.Type.IsString()
183183
}
184184

185185
func (f *Field) IsHandle() bool {
@@ -260,6 +260,15 @@ type Type struct {
260260
Elem *Type `json:"elem,omitempty"`
261261
}
262262

263+
func (t *Type) IsString() bool {
264+
for _, t := range t.flat() {
265+
if t.Attrs != nil && t.Attrs.Usage.IsString {
266+
return true
267+
}
268+
}
269+
return false
270+
}
271+
263272
func (t *Type) flat() []*Type {
264273

265274
var list []*Type

msrpc/dcom/oaut/idispatch/v0/v0.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ func (o *xxx_GetIDsOfNamesOperation) MarshalNDRRequest(ctx context.Context, w nd
972972
}
973973
}
974974
}
975-
// rgszNames {in} (1:{pointer=ref}*(1))(2:{string, alias=LPOLESTR}[dim:0,size_is=cNames]*(1)[dim:0,string](wchar))
975+
// rgszNames {in} (1:{pointer=ref}*(1))(2:{string, alias=LPOLESTR}[dim:0,size_is=cNames]*(1)[dim:0,string,null](wchar))
976976
{
977977
dimSize1 := uint64(o.NamesCount)
978978
if err := w.WriteSize(dimSize1); err != nil {
@@ -988,7 +988,7 @@ func (o *xxx_GetIDsOfNamesOperation) MarshalNDRRequest(ctx context.Context, w nd
988988
}
989989
if o.Names[i1] != "" {
990990
_ptr_rgszNames := ndr.MarshalNDRFunc(func(ctx context.Context, w ndr.Writer) error {
991-
if err := ndr.WriteUTF16String(ctx, w, o.Names[i1]); err != nil {
991+
if err := ndr.WriteUTF16NString(ctx, w, o.Names[i1]); err != nil {
992992
return err
993993
}
994994
return nil
@@ -1048,7 +1048,7 @@ func (o *xxx_GetIDsOfNamesOperation) UnmarshalNDRRequest(ctx context.Context, w
10481048
return err
10491049
}
10501050
}
1051-
// rgszNames {in} (1:{pointer=ref}*(1))(2:{string, alias=LPOLESTR}[dim:0,size_is=cNames]*(1)[dim:0,string](wchar))
1051+
// rgszNames {in} (1:{pointer=ref}*(1))(2:{string, alias=LPOLESTR}[dim:0,size_is=cNames]*(1)[dim:0,string,null](wchar))
10521052
{
10531053
sizeInfo := []uint64{
10541054
0,
@@ -1065,7 +1065,7 @@ func (o *xxx_GetIDsOfNamesOperation) UnmarshalNDRRequest(ctx context.Context, w
10651065
for i1 := range o.Names {
10661066
i1 := i1
10671067
_ptr_rgszNames := ndr.UnmarshalNDRFunc(func(ctx context.Context, w ndr.Reader) error {
1068-
if err := ndr.ReadUTF16String(ctx, w, &o.Names[i1]); err != nil {
1068+
if err := ndr.ReadUTF16NString(ctx, w, &o.Names[i1]); err != nil {
10691069
return err
10701070
}
10711071
return nil

msrpc/dhcpm/dhcpm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9381,7 +9381,7 @@ func (o *MScopeTable) MarshalNDR(ctx context.Context, w ndr.Writer) error {
93819381
}
93829382
if o.MScopeNames[i1] != "" {
93839383
_ptr_pMScopeNames := ndr.MarshalNDRFunc(func(ctx context.Context, w ndr.Writer) error {
9384-
if err := ndr.WriteUTF16String(ctx, w, o.MScopeNames[i1]); err != nil {
9384+
if err := ndr.WriteUTF16NString(ctx, w, o.MScopeNames[i1]); err != nil {
93859385
return err
93869386
}
93879387
return nil
@@ -9439,7 +9439,7 @@ func (o *MScopeTable) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
94399439
for i1 := range o.MScopeNames {
94409440
i1 := i1
94419441
_ptr_pMScopeNames := ndr.UnmarshalNDRFunc(func(ctx context.Context, w ndr.Reader) error {
9442-
if err := ndr.ReadUTF16String(ctx, w, &o.MScopeNames[i1]); err != nil {
9442+
if err := ndr.ReadUTF16NString(ctx, w, &o.MScopeNames[i1]); err != nil {
94439443
return err
94449444
}
94459445
return nil

msrpc/dhcpm/dhcpsrv2/v1/v1.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15753,11 +15753,11 @@ func (o *xxx_AuditLogGetParamsOperation) MarshalNDRResponse(ctx context.Context,
1575315753
if err := o.xxx_PrepareResponsePayload(ctx); err != nil {
1575415754
return err
1575515755
}
15756-
// AuditLogDir {out} (1:{pointer=ref}*(2))(2:{string, alias=LPWSTR_RPC_STRING, names=LPWSTR}*(1)[dim:0,string](wchar))
15756+
// AuditLogDir {out} (1:{pointer=ref}*(2))(2:{string, alias=LPWSTR_RPC_STRING, names=LPWSTR}*(1)[dim:0,string,null](wchar))
1575715757
{
1575815758
if o.AuditLogDir != "" {
1575915759
_ptr_AuditLogDir := ndr.MarshalNDRFunc(func(ctx context.Context, w ndr.Writer) error {
15760-
if err := ndr.WriteUTF16String(ctx, w, o.AuditLogDir); err != nil {
15760+
if err := ndr.WriteUTF16NString(ctx, w, o.AuditLogDir); err != nil {
1576115761
return err
1576215762
}
1576315763
return nil
@@ -15802,10 +15802,10 @@ func (o *xxx_AuditLogGetParamsOperation) MarshalNDRResponse(ctx context.Context,
1580215802
}
1580315803

1580415804
func (o *xxx_AuditLogGetParamsOperation) UnmarshalNDRResponse(ctx context.Context, w ndr.Reader) error {
15805-
// AuditLogDir {out} (1:{pointer=ref}*(2))(2:{string, alias=LPWSTR_RPC_STRING, names=LPWSTR,pointer=ref}*(1)[dim:0,string](wchar))
15805+
// AuditLogDir {out} (1:{pointer=ref}*(2))(2:{string, alias=LPWSTR_RPC_STRING, names=LPWSTR,pointer=ref}*(1)[dim:0,string,null](wchar))
1580615806
{
1580715807
_ptr_AuditLogDir := ndr.UnmarshalNDRFunc(func(ctx context.Context, w ndr.Reader) error {
15808-
if err := ndr.ReadUTF16String(ctx, w, &o.AuditLogDir); err != nil {
15808+
if err := ndr.ReadUTF16NString(ctx, w, &o.AuditLogDir); err != nil {
1580915809
return err
1581015810
}
1581115811
return nil

msrpc/tsgu/tsproxyrpcinterface/v1/v1.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ func (o *EndpointInfo) MarshalNDR(ctx context.Context, w ndr.Writer) error {
810810
}
811811
if o.ResourceName[i1] != "" {
812812
_ptr_resourceName := ndr.MarshalNDRFunc(func(ctx context.Context, w ndr.Writer) error {
813-
if err := ndr.WriteUTF16String(ctx, w, o.ResourceName[i1]); err != nil {
813+
if err := ndr.WriteUTF16NString(ctx, w, o.ResourceName[i1]); err != nil {
814814
return err
815815
}
816816
return nil
@@ -858,7 +858,7 @@ func (o *EndpointInfo) MarshalNDR(ctx context.Context, w ndr.Writer) error {
858858
}
859859
if o.AlternateResourceNames[i1] != "" {
860860
_ptr_alternateResourceNames := ndr.MarshalNDRFunc(func(ctx context.Context, w ndr.Writer) error {
861-
if err := ndr.WriteUTF16String(ctx, w, o.AlternateResourceNames[i1]); err != nil {
861+
if err := ndr.WriteUTF16NString(ctx, w, o.AlternateResourceNames[i1]); err != nil {
862862
return err
863863
}
864864
return nil
@@ -922,7 +922,7 @@ func (o *EndpointInfo) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
922922
for i1 := range o.ResourceName {
923923
i1 := i1
924924
_ptr_resourceName := ndr.UnmarshalNDRFunc(func(ctx context.Context, w ndr.Reader) error {
925-
if err := ndr.ReadUTF16String(ctx, w, &o.ResourceName[i1]); err != nil {
925+
if err := ndr.ReadUTF16NString(ctx, w, &o.ResourceName[i1]); err != nil {
926926
return err
927927
}
928928
return nil
@@ -961,7 +961,7 @@ func (o *EndpointInfo) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
961961
for i1 := range o.AlternateResourceNames {
962962
i1 := i1
963963
_ptr_alternateResourceNames := ndr.UnmarshalNDRFunc(func(ctx context.Context, w ndr.Reader) error {
964-
if err := ndr.ReadUTF16String(ctx, w, &o.AlternateResourceNames[i1]); err != nil {
964+
if err := ndr.ReadUTF16NString(ctx, w, &o.AlternateResourceNames[i1]); err != nil {
965965
return err
966966
}
967967
return nil

0 commit comments

Comments
 (0)