Commit 843ac095 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/snmpd: make t_n_rows static in wrsTableTemplate.h

t_n_rows (n_rows before) has to be local for table. Having it global sometimes
caused to print wrong number of rows in tables. This bug may even cause snmpd
to crash.
It was dependent on the call order of *_data_fill funtions.

Change the n_rows into t_n_rows, since the usage of n_rows variable is common
in the snmp code. By this avoid potential errors like variable overleaping
problems.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent b13e0d8a
/* global variable to keep number of rows, filled by cache function */
unsigned int n_rows;
/* global variable to keep number of rows, filled by cache function
* one for each table */
static unsigned int t_n_rows; /* template n_rows */
static netsnmp_variable_list *
table_next_entry(void **loop_context,
......@@ -10,7 +11,7 @@ table_next_entry(void **loop_context,
intptr_t i;
/* create the line ID from counter number */
i = (intptr_t)*loop_context;
if (i >= n_rows)
if (i >= t_n_rows)
return NULL; /* no more */
i++;
/* Create the row OID: only the counter index */
......@@ -101,7 +102,7 @@ table_handler(netsnmp_mib_handler *handler,
static int table_cache_load(netsnmp_cache *cache, void *vmagic)
{
TT_DATA_FILL_FUNC(&n_rows);
TT_DATA_FILL_FUNC(&t_n_rows);
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment