aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/tls.c
diff options
context:
space:
mode:
authorragostino <74959231+ragostino@users.noreply.github.com>2021-02-03 09:31:17 +0100
committerGitHub <noreply@github.com>2021-02-03 09:31:17 +0100
commitee945349063418882eb7a4a968fe72176c4eda04 (patch)
tree3efb11ea37c2cb1eb8d62e4d93461c13b090c6db /src/lib/protocols/tls.c
parent50f4049b58b9d04a403ba7570935f887aef937db (diff)
debug message bugfix (#1108)
you can not look for memory enlargement if you print debug message after updating the variables
Diffstat (limited to 'src/lib/protocols/tls.c')
-rw-r--r--src/lib/protocols/tls.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c
index 0197b0a23..0eebe7773 100644
--- a/src/lib/protocols/tls.c
+++ b/src/lib/protocols/tls.c
@@ -139,18 +139,18 @@ void ndpi_search_tls_tcp_memory(struct ndpi_detection_module_struct *ndpi_struct
avail_bytes = flow->l4.tcp.tls.message.buffer_len - flow->l4.tcp.tls.message.buffer_used;
if(avail_bytes < packet->payload_packet_len) {
- u_int new_len = flow->l4.tcp.tls.message.buffer_len + packet->payload_packet_len;
+ u_int new_len = flow->l4.tcp.tls.message.buffer_len + packet->payload_packet_len - avail_bytes + 1;
void *newbuf = ndpi_realloc(flow->l4.tcp.tls.message.buffer,
flow->l4.tcp.tls.message.buffer_len, new_len);
if(!newbuf) return;
- flow->l4.tcp.tls.message.buffer = (u_int8_t*)newbuf;
- flow->l4.tcp.tls.message.buffer_len = new_len;
- avail_bytes = flow->l4.tcp.tls.message.buffer_len - flow->l4.tcp.tls.message.buffer_used;
-
#ifdef DEBUG_TLS_MEMORY
printf("[TLS Mem] Enlarging %u -> %u buffer\n", flow->l4.tcp.tls.message.buffer_len, new_len);
#endif
+
+ flow->l4.tcp.tls.message.buffer = (u_int8_t*)newbuf;
+ flow->l4.tcp.tls.message.buffer_len = new_len;
+ avail_bytes = flow->l4.tcp.tls.message.buffer_len - flow->l4.tcp.tls.message.buffer_used;
}
if(packet->payload_packet_len > 0 && avail_bytes >= packet->payload_packet_len) {