Skip to content

Commit f14a955

Browse files
rlubosnashif
authored andcommitted
net: lwm2m: Make query buffer large enough to encode all query strings
Make sure query string used by the lwm2m_rd_client is large enough to encode any query string that can be sent during bootstrap/registration. As the maximum query string length is related to the endpoint name, which is limited by `CONFIG_LWM2M_RD_CLIENT_ENDPOINT_NAME_MAX_LENGTH`, make the query string corellated to the value of this config. Signed-off-by: Robert Lubos <[email protected]>
1 parent dbbdef1 commit f14a955

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

subsys/net/lib/lwm2m/lwm2m_rd_client.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,12 @@ struct lwm2m_rd_client_info {
116116
bool update_objects : 1;
117117
} client;
118118

119-
/* buffers */
120-
static char query_buffer[64]; /* allocate some data for queries and updates */
119+
/* Allocate some data for queries and updates. Make sure it's large enough to
120+
* hold the largest query string, which in most cases will be the endpoint
121+
* string. In other case, 32 bytes are enough to encode any other query string
122+
* documented in the LwM2M specification.
123+
*/
124+
static char query_buffer[MAX(32, sizeof("ep=") + CLIENT_EP_LEN)];
121125
static uint8_t client_data[256]; /* allocate some data for the RD */
122126

123127
void engine_update_tx_time(void)

0 commit comments

Comments
 (0)