Skip to contentSkip to conversation

fix parsing of statistics type-attribute

PATCH New Martin Peschke 1 participant 1 message Mar 6, 2007 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix parsing of statistics type-attribute

Without this fix the the statistics user interface accepted, for example:

echo name=my_stats type=utilisa > definition

while it should only accept:

echo name=my_stats type=utilisation > definition

---

 statistic.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/statistic.c +2 -1
Index: linux/lib/statistic.c
===================================================================
@@ -506,7 +506,8 @@ static int statistic_parse_match(struct 
 		len = (args[0].to - args[0].from);
 		for (type = 0; type < STAT_NONE; type++) {
 			disc = &statistic_discs[type];
-			if (unlikely(strncmp(disc->name, args[0].from, len)))
+			if (strlen(disc->name) != len ||
+			    strncmp(disc->name, args[0].from, len))
 				continue;
 			return statistic_parse_single(stat, info, def, type);
 		}