mirror of
https://github.com/nmap/nmap.git
synced 2026-09-02 08:20:52 +00:00
Silence static analysis warning
LGTM points out that since comparison with sizeof(buf) coerces n to unsigned, all negative values become very large values, which are necessarily larger than sizeof(buf), so the test is redundant. We still want the test in our code to be explicit that we are checking for it, so reordering the comparisons should silence the warning. A good optimizing compiler should be able to combine the two conditions anyway. See https://github.com/github/codeql/issues/4249
This commit is contained in:
parent
fa6bd3f901
commit
75318985a1
1 changed files with 1 additions and 1 deletions
|
|
@ -1197,7 +1197,7 @@ static int chat_announce_disconnect(int fd)
|
|||
|
||||
n = Snprintf(buf, sizeof(buf),
|
||||
"<announce> <user%d> is disconnected.\n", fd);
|
||||
if (n >= sizeof(buf) || n < 0)
|
||||
if (n < 0 || n >= sizeof(buf))
|
||||
return -1;
|
||||
|
||||
return ncat_broadcast(&master_broadcastfds, &broadcast_fdlist, buf, n);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue