aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ndpi_classify.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2024-01-12 13:30:43 +0100
committerGitHub <noreply@github.com>2024-01-12 13:30:43 +0100
commitdd8be1fcb11089b22ab5eb7332d5640b4cae80b0 (patch)
tree775a44bbbaeced406a3df3931f5d786f7a517e15 /src/lib/ndpi_classify.c
parent0aea509e23e0f0bd368f4796dcf0542d5c9108c7 (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/ndpi_classify.c')
-rw-r--r--src/lib/ndpi_classify.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/ndpi_classify.c b/src/lib/ndpi_classify.c
index b8bf8213d..78a5222a6 100644
--- a/src/lib/ndpi_classify.c
+++ b/src/lib/ndpi_classify.c
@@ -559,9 +559,9 @@ ndpi_classify (const unsigned short *pkt_len, const pkt_timeval *pkt_time,
void
ndpi_update_params (classifier_type_codes_t param_type, const char *param_file)
{
- float param;
+ float param = 0.0;
FILE *fp;
- int count = 0;
+ int count;
switch (param_type) {
case (SPLT_PARAM_TYPE):
@@ -711,7 +711,7 @@ ndpi_log_timestamp(char *log_ts, uint32_t log_ts_len)
{
pkt_timeval tv;
time_t nowtime;
- struct tm nowtm_r;
+ struct tm nowtm_r = { 0 };
char tmbuf[NDPI_TIMESTAMP_LEN];
gettimeofday(&tv, NULL);