diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2024-01-12 13:30:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-12 13:30:43 +0100 |
commit | dd8be1fcb11089b22ab5eb7332d5640b4cae80b0 (patch) | |
tree | 775a44bbbaeced406a3df3931f5d786f7a517e15 /src/lib/protocols/checkmk.c | |
parent | 0aea509e23e0f0bd368f4796dcf0542d5c9108c7 (diff) |
Fix some warnings reported by CODESonar (#2227)
Remove some unreached/duplicated code.
Add error checking for `atoi()` calls.
About `isdigit()` and similar functions. The warning reported is:
```
Negative Character Value help
isdigit() is invoked here with an argument of signed type char, but only
has defined behavior for int arguments that are either representable
as unsigned char or equal to the value of macro EOF(-1).
Casting the argument to unsigned char will avoid the undefined behavior.
In a number of libc implementations, isdigit() is implemented using lookup
tables (arrays): passing in a negative value can result in a read underrun.
```
Switching to our macros fix that.
Add a check to `check_symbols.sh` to avoid using the original functions
from libc.
Diffstat (limited to 'src/lib/protocols/checkmk.c')
-rw-r--r-- | src/lib/protocols/checkmk.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib/protocols/checkmk.c b/src/lib/protocols/checkmk.c index c70e2a478..cfc70f451 100644 --- a/src/lib/protocols/checkmk.c +++ b/src/lib/protocols/checkmk.c @@ -60,7 +60,7 @@ static void ndpi_search_checkmk(struct ndpi_detection_module_struct *ndpi_struct * this will detect the OpenSession command of the Data Stream Interface (DSI) protocol * which is exclusively used by the Apple Filing Protocol (AFP) on TCP/IP networks */ - if (packet->payload_packet_len >= 15 && packet->payload_packet_len < 100 + if (packet->payload_packet_len < 100 && memcmp(packet->payload, "<<<check_mk>>>", 14) == 0) { NDPI_LOG_DBG(ndpi_struct, "Check_MK: Flow detected.\n"); |