Skip to content

Commit

Permalink
Beachfront: Fix Shared Memory Overwriting (prebid#1762)
Browse files Browse the repository at this point in the history
* Fix race condition in Beachfront adapter

* Removed nil check and simplified
  • Loading branch information
guscarreon authored and Dan Barnett committed May 11, 2021
1 parent dab1e96 commit 0128cca
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions adapters/beachfront/beachfront.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,22 +409,27 @@ func getVideoRequests(request *openrtb.BidRequest) ([]beachfrontVideoRequest, []
bfReqs[i].Request = *request
var secure int8

var deviceCopy openrtb.Device
if bfReqs[i].Request.Device == nil {
bfReqs[i].Request.Device = &openrtb.Device{}
deviceCopy = openrtb.Device{}
} else {
deviceCopy = *bfReqs[i].Request.Device
}

if beachfrontExt.VideoResponseType == "nurl" {
bfReqs[i].VideoResponseType = "nurl"
} else {
bfReqs[i].VideoResponseType = "adm"

if bfReqs[i].Request.Device.IP == "" {
bfReqs[i].Request.Device.IP = fakeIP
if deviceCopy.IP == "" {
deviceCopy.IP = fakeIP
}
}

if bfReqs[i].Request.Site != nil && bfReqs[i].Request.Site.Domain == "" && bfReqs[i].Request.Site.Page != "" {
bfReqs[i].Request.Site.Domain = getDomain(bfReqs[i].Request.Site.Page)
siteCopy := *bfReqs[i].Request.Site
siteCopy.Domain = getDomain(bfReqs[i].Request.Site.Page)
bfReqs[i].Request.Site = &siteCopy
secure = isSecure(bfReqs[i].Request.Site.Page)
}

Expand All @@ -439,10 +444,11 @@ func getVideoRequests(request *openrtb.BidRequest) ([]beachfrontVideoRequest, []
}
}

if bfReqs[i].Request.Device != nil && bfReqs[i].Request.Device.DeviceType == 0 {
if deviceCopy.DeviceType == 0 {
// More fine graned deviceType methods will be added in the future
bfReqs[i].Request.Device.DeviceType = fallBackDeviceType(request)
deviceCopy.DeviceType = fallBackDeviceType(request)
}
bfReqs[i].Request.Device = &deviceCopy

imp := request.Imp[i]

Expand Down

0 comments on commit 0128cca

Please sign in to comment.