Skip to content

Commit 0cefc69

Browse files
Tomasz BursztykaAnas Nashif
authored andcommitted
samples/zoap_server: Fix unchecked return value
Coverity-CID: 174413 Jira: ZEP-2523 Signed-off-by: Tomasz Bursztyka <[email protected]>
1 parent 9034d73 commit 0cefc69

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

samples/net/zoap_server/src/zoap-server.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,11 @@ static int test_post(struct zoap_resource *resource,
217217
zoap_header_set_token(&response, token, tkl);
218218

219219
for (p = location_path; *p; p++) {
220-
zoap_add_option(&response, ZOAP_OPTION_LOCATION_PATH,
221-
*p, strlen(*p));
220+
r = zoap_add_option(&response, ZOAP_OPTION_LOCATION_PATH,
221+
*p, strlen(*p));
222+
if (r < 0) {
223+
return -EINVAL;
224+
}
222225
}
223226

224227
return net_context_sendto(pkt, from, sizeof(struct sockaddr_in6),
@@ -280,8 +283,11 @@ static int location_query_post(struct zoap_resource *resource,
280283
zoap_header_set_token(&response, token, tkl);
281284

282285
for (p = location_query; *p; p++) {
283-
zoap_add_option(&response, ZOAP_OPTION_LOCATION_QUERY,
284-
*p, strlen(*p));
286+
r = zoap_add_option(&response, ZOAP_OPTION_LOCATION_QUERY,
287+
*p, strlen(*p));
288+
if (r < 0) {
289+
return -EINVAL;
290+
}
285291
}
286292

287293
return net_context_sendto(pkt, from, sizeof(struct sockaddr_in6),

0 commit comments

Comments
 (0)