Skip to content

Commit

Permalink
Improved missing usage of nDPIs malloc wrapper. Fixes ntop#1978.
Browse files Browse the repository at this point in the history
 * added CI check

Signed-off-by: lns <[email protected]>
  • Loading branch information
utoni committed May 17, 2023
1 parent 8c224b4 commit 3d76e02
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,17 @@ jobs:
- name: Print nDPI long help
if: startsWith(matrix.arch, 'x86_64') && !startsWith(matrix.os, 'windows')
run: |
./example/ndpiReader -H
./example/ndpiReader -H
- name: Install nDPI
if: startsWith(matrix.arch, 'x86_64') && !startsWith(matrix.os, 'windows')
run: |
make install DESTDIR=$(realpath _install)
ls -alhHR _install
# - name: Test nDPI [LIBRARY]
# if: !startsWith(matrix.os, 'windows')
# run: |
# echo 'Checking for malloc/calloc/free symbols..'
# test "$(nm -u src/lib/libndpi.a | grep 'U \(malloc\|calloc\|realloc\|free\)' | wc -l)" -eq 8 || echo "::error file=src/lib/libndpi.a::Unwanted libc symbols found."
- name: Test nDPI [DIFF]
if: startsWith(matrix.arch, 'x86_64') && !startsWith(matrix.os, 'windows')
run: |
Expand Down
1 change: 1 addition & 0 deletions src/lib/ndpi_content_match.c.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ static ndpi_protocol_match host_match[] =
{ "zattosecurehd2-f.akamaihd.net", "Zattoo", NDPI_PROTOCOL_ZATTOO, NDPI_PROTOCOL_CATEGORY_VIDEO, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_DEFAULT_LEVEL },

{ "classroom.google.com", "GoogleClassroom", NDPI_PROTOCOL_GOOGLE_CLASSROOM, NDPI_PROTOCOL_CATEGORY_COLLABORATIVE, NDPI_PROTOCOL_SAFE, NDPI_PROTOCOL_DEFAULT_LEVEL },
{ "backup.googleapis.com", "GoogleCloud", NDPI_PROTOCOL_GOOGLE_CLOUD, NDPI_PROTOCOL_CATEGORY_CLOUD, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_DEFAULT_LEVEL },

{ "fortinet.com", "Cybersec", NDPI_PROTOCOL_CYBERSECURITY, NDPI_PROTOCOL_CATEGORY_CYBERSECURITY, NDPI_PROTOCOL_SAFE, NDPI_PROTOCOL_DEFAULT_LEVEL },
{ "sophos.com", "Cybersec", NDPI_PROTOCOL_CYBERSECURITY, NDPI_PROTOCOL_CATEGORY_CYBERSECURITY, NDPI_PROTOCOL_SAFE, NDPI_PROTOCOL_DEFAULT_LEVEL },
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ndpi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3345,7 +3345,7 @@ static void free_ptree_data(void *data) {
while(item != NULL) {
struct patricia_uv16_list *next = item->next;

free(item);
ndpi_free(item);
item = next;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ndpi_serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,13 @@ void ndpi_term_serializer(ndpi_serializer *_serializer) {
ndpi_private_serializer *serializer = (ndpi_private_serializer*)_serializer;

if(serializer->buffer.data) {
free(serializer->buffer.data);
ndpi_free(serializer->buffer.data);
serializer->buffer.size = 0;
serializer->buffer.data = NULL;
}

if(serializer->header.data) {
free(serializer->header.data);
ndpi_free(serializer->header.data);
serializer->header.size = 0;
serializer->header.data = NULL;
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/ndpi_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ static void ndpi_compile_rce_regex() {
#endif
}

free((void *)pcreErrorStr);
ndpi_free((void *)pcreErrorStr);
}

static int ndpi_is_rce_injection(char* query) {
Expand Down Expand Up @@ -2253,7 +2253,7 @@ void ndpi_hash_free(ndpi_str_hash **h, void (*cleanup_func)(ndpi_str_hash *h))
{
cleanup_func((ndpi_str_hash *)current);
}
free(current);
ndpi_free(current);
}

*h = NULL;
Expand Down Expand Up @@ -2415,7 +2415,7 @@ static void ndpi_handle_risk_exceptions(struct ndpi_detection_module_struct *ndp
*/
for(i=0; i<flow->num_risk_infos; i++) {
if(flow->risk_infos[i].info != NULL) {
free(flow->risk_infos[i].info);
ndpi_free(flow->risk_infos[i].info);
flow->risk_infos[i].info = NULL;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/third_party/src/gcrypt/aesni.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int mbedtls_aesni_has_support( unsigned int what )
break; /* We giveup */
}

free(line);
ndpi_free(line);
fclose(fd);

has_aesni_checked = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/third_party/src/gcrypt_light.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/****************************/

#define mbedtls_calloc ndpi_calloc
#define mbedtls_free ndpi_free
#define mbedtls_free ndpi_free

#include "gcrypt_light.h"

Expand Down

0 comments on commit 3d76e02

Please sign in to comment.