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:
Flavio Ceolin 2022-05-19 04:07:38 -07:00 committed by Carles Cufí
commit ac2e13b9a1

View file

@ -238,8 +238,10 @@ static const char *tcp_flags(uint8_t flags)
len += snprintk(buf + len, BUF_SIZE - len, "URG,");
}
if (len > 0) {
buf[len - 1] = '\0'; /* delete the last comma */
}
}
#undef BUF_SIZE
return buf;
}