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

Fix combination of blockwise and observe #576

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ v3/

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
.scannerwork/
5 changes: 0 additions & 5 deletions net/blockwise/blockwise.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
if blockNumber > maxBlockNumber {
return 0, ErrBlockNumberExceedLimit
}
blockVal := uint32(blockNumber << 4)

Check failure on line 101 in net/blockwise/blockwise.go

View workflow job for this annotation

GitHub Actions / lint

G115: integer overflow conversion int64 -> uint32 (gosec)
m := uint32(0)
if moreBlocksFollowing {
m = 1
Expand All @@ -115,7 +115,7 @@
return
}

szx = SZX(blockVal & szxMask) // masking for the SZX

Check failure on line 118 in net/blockwise/blockwise.go

View workflow job for this annotation

GitHub Actions / lint

G115: integer overflow conversion uint32 -> uint8 (gosec)
if (blockVal & moreBlocksFollowingMask) != 0 { // masking for the "M"
moreBlocksFollowing = true
}
Expand Down Expand Up @@ -238,7 +238,7 @@
}
req := b.cloneMessage(r)
defer b.cc.ReleaseMessage(req)
req.SetOptionUint32(message.Size1, uint32(payloadSize))

Check failure on line 241 in net/blockwise/blockwise.go

View workflow job for this annotation

GitHub Actions / lint

G115: integer overflow conversion int64 -> uint32 (gosec)
block, err := EncodeBlockOption(maxSzx, 0, true)
if err != nil {
return nil, fmt.Errorf("cannot encode block option(%v, %v, %v) to bw request: %w", maxSzx, 0, true, err)
Expand Down Expand Up @@ -477,7 +477,7 @@
if offSeek+int64(readed) == payloadSize {
more = false
}
sendMessage.SetOptionUint32(sizeType, uint32(payloadSize))

Check failure on line 480 in net/blockwise/blockwise.go

View workflow job for this annotation

GitHub Actions / lint

G115: integer overflow conversion int64 -> uint32 (gosec)
num = (offSeek) / szx.Size()
block, err = EncodeBlockOption(szx, num, more)
if err != nil {
Expand Down Expand Up @@ -540,11 +540,6 @@
return fmt.Errorf("handleSendingMessage: cannot create sending message: %w", err)
}
originalSendingMessage := w.Swap(sendingMessage)
if isObserveResponse(w.Message()) {
b.cc.ReleaseMessage(originalSendingMessage)
// https://tools.ietf.org/html/rfc7959#section-2.6 - we don't need store it because client will be get values via GET.
return nil
}
expire, ok := sendingMessage.Context().Deadline()
if !ok {
expire = time.Now().Add(b.expiration)
Expand Down
Loading