Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beachfront: Fix Shared Memory Overwriting #1762

Merged
merged 2 commits into from
Mar 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions adapters/beachfront/beachfront.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,22 +407,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{}
Copy link
Collaborator

@hhhjort hhhjort Mar 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't line 410 already do this? I think you only need one of these two lines.

Nevermind, I see 410's purpose is to get the scope of deviceCopy outside of the if statement. 412 might not be necessary, not sure if 410 will create a new object each run through the loop, or reuse the old one.

} 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 @@ -437,10 +442,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