diff options
author | Luca Deri <deri@ntop.org> | 2020-08-06 09:19:04 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2020-08-06 09:19:04 +0200 |
commit | c2156a516193ada6fee37ab6b7a26f712ee02e14 (patch) | |
tree | 646203aa870b1f75caf6a2def88cb231010a6f3c /src | |
parent | 5b6ffad2788ad3590426d2573d981705702b1f53 (diff) |
Added note on memory management
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ndpi_api.h.in | 2 | ||||
-rw-r--r-- | src/lib/ndpi_community_id.c | 4 | ||||
-rw-r--r-- | src/lib/ndpi_utils.c | 1 |
3 files changed, 4 insertions, 3 deletions
diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in index 6c01bb05c..e5d2ffad3 100644 --- a/src/include/ndpi_api.h.in +++ b/src/include/ndpi_api.h.in @@ -903,7 +903,7 @@ extern "C" { void ndpi_user_pwd_payload_copy(u_int8_t *dest, u_int dest_len, u_int offset, const u_int8_t *src, u_int src_len); u_char* ndpi_base64_decode(const u_char *src, size_t len, size_t *out_len); - char* ndpi_base64_encode(unsigned char const* bytes_to_encode, size_t in_len); + char* ndpi_base64_encode(unsigned char const* bytes_to_encode, size_t in_len); /* NOTE: caller MUST free the returned pointer */ void ndpi_string_sha1_hash(const uint8_t *message, size_t len, u_char *hash /* 20-bytes */); int ndpi_load_ipv4_ptree(struct ndpi_detection_module_struct *ndpi_str, diff --git a/src/lib/ndpi_community_id.c b/src/lib/ndpi_community_id.c index 3d7b1173d..72f60c746 100644 --- a/src/lib/ndpi_community_id.c +++ b/src/lib/ndpi_community_id.c @@ -217,7 +217,7 @@ static int ndpi_community_id_finalize_and_compute_hash(u_int8_t *comm_buf, u_int /* Base64 encoding */ community_id = ndpi_base64_encode((u_int8_t*)hash, sizeof(hash)); - if (community_id == NULL) + if(community_id == NULL) return -1; #if 0 /* Debug Info */ @@ -234,7 +234,7 @@ static int ndpi_community_id_finalize_and_compute_hash(u_int8_t *comm_buf, u_int printf("Base64: %s\n", community_id); #endif - if (hash_buf_len < 2 || hash_buf_len-2 < strlen(community_id)+1) { + if(hash_buf_len < 2 || hash_buf_len-2 < strlen(community_id)+1) { ndpi_free(community_id); return -1; } diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index 347e65d52..00583dd26 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -874,6 +874,7 @@ u_char* ndpi_base64_decode(const u_char *src, size_t len, size_t *out_len) { /* ********************************** */ +/* NOTE: caller MUST free returned pointer */ char* ndpi_base64_encode(unsigned char const* bytes_to_encode, size_t in_len) { size_t len = 0, ret_size; char *ret; |