net: tcp: Fix possible buffer underflow
Fix possible underflow in tcp flags parse. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
8148449db0
commit
ac2e13b9a1
1 changed files with 3 additions and 1 deletions
|
@ -238,7 +238,9 @@ static const char *tcp_flags(uint8_t flags)
|
|||
len += snprintk(buf + len, BUF_SIZE - len, "URG,");
|
||||
}
|
||||
|
||||
buf[len - 1] = '\0'; /* delete the last comma */
|
||||
if (len > 0) {
|
||||
buf[len - 1] = '\0'; /* delete the last comma */
|
||||
}
|
||||
}
|
||||
#undef BUF_SIZE
|
||||
return buf;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue