Skip to content

coap: block_number in coap_get_block1_option() is too small #76000

Closed
@yashi

Description

@yashi

Describe the bug

RFC 7959 states that the Block Number can be more than 8 bits.

           0
           0 1 2 3 4 5 6 7
          +-+-+-+-+-+-+-+-+
          |  NUM  |M| SZX |
          +-+-+-+-+-+-+-+-+

           0                   1
           0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
          |          NUM          |M| SZX |
          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

           0                   1                   2
           0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
          |                   NUM                 |M| SZX |
          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Figure 1: Block Option Value

However, block_number in coap_get_block1_option() and coap_get_block2_option() is declared as uint8_t.

To Reproduce
Try samples/net/sockets/coap_server/ with coap_get_option_int() replaced with coap_get_block1_option()

Expected behavior

block_number to be unsigned int.

Impact
Block number is truncated when using the APIs.

Environment (please complete the following information):

  • OS: Linux Debian Sid
  • Toolchain: Zephyr SDK v0.16.6
  • Commit SHA: v3.7.0-rc3-25-gcb17f5f5a4af

Metadata

Metadata

Assignees

Labels

area: NetworkingbugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions