Skip to content

Commit

Permalink
Merge pull request #541 from uber/tahmid.fixslice
Browse files Browse the repository at this point in the history
Fix unsafe slice accesses when reading ref annotation
  • Loading branch information
tahmidhasan authored Jan 9, 2019
2 parents 53fa08b + 59ac818 commit 6f0903f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions codegen/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (ms *MethodSpec) scanForNonParams(funcSpec *compile.FunctionSpec) bool {
}

param, ok := field.Annotations[ms.annotations.HTTPRef]
if !ok || param[0:6] != "params" {
if !ok || strings.HasPrefix(param, "params") {
hasNonParams = true
return true
}
Expand Down Expand Up @@ -618,7 +618,7 @@ func (ms *MethodSpec) setEndpointRequestHeaderFields(
}

if param, ok := field.Annotations[ms.annotations.HTTPRef]; ok {
if param[0:8] == "headers." {
if strings.HasPrefix(param, "headers.") {
headerName := param[8:]
camelHeaderName := CamelCase(headerName)

Expand Down Expand Up @@ -744,7 +744,7 @@ func (ms *MethodSpec) setResponseHeaderFields(
goPrefix string, thriftPrefix string, field *compile.FieldSpec,
) bool {
if param, ok := field.Annotations[ms.annotations.HTTPRef]; ok {
if param[0:8] == "headers." {
if strings.HasPrefix(param, "headers.") {
headerName := param[8:]
ms.ResHeaderFields[headerName] = HeaderFieldInfo{
FieldIdentifier: goPrefix + "." + PascalCase(field.Name),
Expand Down Expand Up @@ -786,7 +786,7 @@ func (ms *MethodSpec) setClientRequestHeaderFields(
}

if param, ok := field.Annotations[ms.annotations.HTTPRef]; ok {
if param[0:8] == "headers." {
if strings.HasPrefix(param, "headers.") {
headerName := param[8:]
bodyIdentifier := goPrefix + "." + PascalCase(field.Name)
var headerNameValuePair string
Expand Down

0 comments on commit 6f0903f

Please sign in to comment.