diff options
author | Luca Deri <deri@ntop.org> | 2022-05-30 01:12:38 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2022-05-30 01:12:38 +0200 |
commit | 897f8314b29cd7de9eeab9af15b3e189ae6724a1 (patch) | |
tree | 3f8ead345435ae44f3e5e63c05c591e831277930 /src/lib/ndpi_utils.c | |
parent | 1da9f1a36fc2f60d8a2f13fca88a7675d327e3ad (diff) |
Fixed dispay bug for risk_info
Diffstat (limited to 'src/lib/ndpi_utils.c')
-rw-r--r-- | src/lib/ndpi_utils.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index 3f98ef0a7..c4ab36238 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -2529,9 +2529,9 @@ char* ndpi_get_flow_risk_info(struct ndpi_flow_struct *flow, if((out == NULL) || (flow->num_risk_infos == 0)) return(NULL); - out[0] = '\0'; + out[0] = '\0', out_len--; - for(i=0; i<flow->num_risk_infos; i++) { + for(i=0; (i<flow->num_risk_infos) && (out_len > offset); i++) { int rc = snprintf(&out[offset], out_len-offset, "%s%s", (i == 0) ? "" : " / ", flow->risk_infos[i]); @@ -2542,6 +2542,8 @@ char* ndpi_get_flow_risk_info(struct ndpi_flow_struct *flow, offset += rc; } + if(offset > out_len) offset = out_len; + out[offset] = '\0'; return(out[0] == '\0' ? NULL : out); |