On mån, 2008-06-30 at 10:36 -0700, Stephen Hemminger wrote: > The problem is that MAX_FIELDS is 64, but lnstat is finding 71 fields. > This causes a array out of range problem. > > Just bump MAX_FIELDS to 128
Oh, stupid me to not catch that when I was thinking it used un-allocated memory and all... Here's a patch that prevents the overflow and throws a warning instead. diff --git a/misc/lnstat.c b/misc/lnstat.c index b56598a..5a0c349 100644 --- a/misc/lnstat.c +++ b/misc/lnstat.c @@ -121,6 +121,10 @@ static int map_field_params(struct lnstat_file *lnstat_files, if (!fps->params[j].print.width) fps->params[j].print.width = FIELD_WIDTH_DEFAULT; + if (j >= MAX_FIELDS) { + fprintf(stderr, "WARN: MAX_FIELDS (%d) reached, truncating input data.\n", MAX_FIELDS); + break; + } j++; } } @@ -269,8 +273,10 @@ int main(int argc, char **argv) for (tok = strtok(tmp, ","); tok; tok = strtok(NULL, ",")) { - if (fp.num >= MAX_FIELDS) + if (fp.num >= MAX_FIELDS) { + fprintf(stderr, "WARN: MAX_FIELDS (%d) reached, truncating given keys.\n", MAX_FIELDS); break; + } fp.params[fp.num++].name = tok; } break; -- Regards, Andreas Henriksson -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]