Skip to content

Commit

Permalink
Fix ndpi_get_lru_cache_stats() (#2303)
Browse files Browse the repository at this point in the history
Found while fuzzing
  • Loading branch information
IvanNardi authored Feb 5, 2024
1 parent f2b0901 commit 66371c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/lib/ndpi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9962,15 +9962,17 @@ int ndpi_get_lru_cache_stats(struct ndpi_global_context *g_ctx,
struct ndpi_lru_cache_stats *stats)
{
int scope, is_local = 1;
char param[64], buf[8];
char param[64], buf[8], *rc;

if(!stats || (!ndpi_struct && !g_ctx))
return -1;
if(!ndpi_struct) {
is_local = 0;
} else {
snprintf(param, sizeof(param), "lru.%s.scope", ndpi_lru_cache_idx_to_name(cache_type));
ndpi_get_config(ndpi_struct, NULL, param, buf, sizeof(buf));
rc = ndpi_get_config(ndpi_struct, NULL, param, buf, sizeof(buf));
if(rc == NULL)
return -1;
scope = atoi(buf);
if(scope == NDPI_LRUCACHE_SCOPE_GLOBAL) {
is_local = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ndpi_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3104,6 +3104,6 @@ const char *ndpi_lru_cache_idx_to_name(lru_cache_type idx)
"tls_cert", "mining", "msteams", "stun_zoom" };

if(idx < 0 || idx >= NDPI_LRUCACHE_MAX)
return NULL;
return "unknown";
return names[idx];
}

0 comments on commit 66371c2

Please sign in to comment.