From 36524ac0fdb05928c2196dc4a55a65bcb4ae04ad Mon Sep 17 00:00:00 2001 From: albert <> Date: Sun, 30 Oct 2005 06:03:28 +0000 Subject: [PATCH] vmstat: -p handles /dev/ and does not overflow #319523 #330969 --- NEWS | 1 + vmstat.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index aec9b911..4108fa5d 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ ps: fix crash related to realloc -- thanks David Houlder ps: man page more detailed #334682 spelling fixes #300333 #334684 #334685 top: crash on resize fixed -- thanks Michal Maruska #320289 +vmstat: -p handles /dev/ and does not overflow #319523 #330969 procps-3.2.4 --> procps-3.2.5 diff --git a/vmstat.c b/vmstat.c index 2bbe0241..b2f1a9e7 100644 --- a/vmstat.c +++ b/vmstat.c @@ -608,10 +608,12 @@ int main(int argc, char *argv[]) { case 'p': statMode |= PARTITIONSTAT; if (argv[1]){ - ++argv; - sprintf(partition, "%s", *argv); - }else{fprintf(stderr, "-p requires an argument\n"); - exit(EXIT_FAILURE); + char *cp = *++argv; + if(!memcmp(cp,"/dev/",5)) cp += 5; + snprintf(partition, sizeof partition, "%s", cp); + }else{ + fprintf(stderr, "-p requires an argument\n"); + exit(EXIT_FAILURE); } break; case 'S':