Skip to content

Commit 7c13b8f

Browse files
committed
CellularUtil prefer_ipv6: check length.
Fixes Coverity issue about not checking the length of string before copying it.
1 parent f513bce commit 7c13b8f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

features/cellular/framework/common/CellularUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void prefer_ipv6(char *ip, size_t ip_size, char *ip2, size_t ip2_size)
236236
if (temp) {
237237
// ipv6 was found in ip2 but not in ip ---> we must swap them. Sadly ip and ip2 might not be pointers
238238
// so we can't just swap them, must use copy.
239-
if (strlen(ip) < ip2_size && strlen(ip2) < ip_size && strlen(ip) < 64) {
239+
if (strlen(ip) < ip2_size && strlen(ip2) < ip_size && strlen(ip) < 64 && strlen(ip2) < 64) {
240240
char tmp[64];
241241
strncpy(tmp, ip, strlen(ip));
242242
tmp[strlen(ip)] = '\0';

0 commit comments

Comments
 (0)