Skip to content

Commit c09b95f

Browse files
Flavio Ceolincfriedt
authored andcommitted
net: tcp: Fix possible buffer underflow
Fix possible underflow in tcp flags parse. Signed-off-by: Flavio Ceolin <[email protected]> (cherry picked from commit ac2e13b)
1 parent 88f09f2 commit c09b95f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

subsys/net/ip/tcp2.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ static const char *tcp_flags(uint8_t flags)
231231
len += snprintk(buf + len, BUF_SIZE - len, "URG,");
232232
}
233233

234-
buf[len - 1] = '\0'; /* delete the last comma */
234+
if (len > 0) {
235+
buf[len - 1] = '\0'; /* delete the last comma */
236+
}
235237
}
236238
#undef BUF_SIZE
237239
return buf;

0 commit comments

Comments
 (0)