summaryrefslogtreecommitdiff
path: root/usr/src/lib/libcpc
diff options
context:
space:
mode:
authorvk226950 <none@none>2008-07-17 11:46:59 -0700
committervk226950 <none@none>2008-07-17 11:46:59 -0700
commitd0ecda70e958c51a970bcec3ea2d03e2d177ff73 (patch)
treecbdc6251736335436e1a8cf9bb585ef40bd64ab2 /usr/src/lib/libcpc
parent51ed222c2fc6323afd9dbad575738fe07eda3247 (diff)
downloadillumos-joyent-d0ecda70e958c51a970bcec3ea2d03e2d177ff73.tar.gz
6595460 Incorrect picno is assigned by cpustat/cputrack for eventnames with numbers.
Diffstat (limited to 'usr/src/lib/libcpc')
-rw-r--r--usr/src/lib/libcpc/common/libcpc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr/src/lib/libcpc/common/libcpc.c b/usr/src/lib/libcpc/common/libcpc.c
index 058e163ccd..df431abcc4 100644
--- a/usr/src/lib/libcpc/common/libcpc.c
+++ b/usr/src/lib/libcpc/common/libcpc.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -1074,6 +1074,7 @@ static int
cpc_valid_event(cpc_t *cpc, uint_t pic, const char *ev)
{
struct priv pr = { NULL, 0 };
+ char *end_ev;
pr.name = ev;
cpc_walk_events_pic(cpc, pic, &pr, ev_walker);
@@ -1085,8 +1086,10 @@ cpc_valid_event(cpc_t *cpc, uint_t pic, const char *ev)
* a raw event code. An event code of '0' is not recognized, as it
* already has a corresponding event name in existing backends and it
* is the only reasonable way to know if strtol() succeeded.
+ * Check the second argument of strtol() to ensure invalid events
+ * beginning with number do not go through.
*/
- if (strtol(ev, NULL, 0) != 0)
+ if ((strtol(ev, &end_ev, 0) != 0) && (*end_ev == '\0'))
/*
* Success - this is a valid raw code in hex, decimal, or octal.
*/