[PATCH] blkparse: remember to bail out if conversion gets too large
authorJens Axboe <axboe@suse.de>
Mon, 10 Oct 2005 10:52:39 +0000 (12:52 +0200)
committerJens Axboe <axboe@suse.de>
Mon, 10 Oct 2005 10:52:39 +0000 (12:52 +0200)
blkparse.c

index 7317f6c58e9b666e0d5ecc511a94fa7e09004241..8fcbe8ea48f0a4a7ae0bd4fdf1780f92ee12e36a 100644 (file)
@@ -1100,12 +1100,12 @@ static void dump_trace(struct blk_io_trace *t, struct per_cpu_info *pci,
 static char *size_cnv(char *dst, unsigned long long num, int in_kb)
 {
        static char suff[] = { '\0', 'K', 'M', 'G', 'P' };
-       int i = 0;
+       unsigned int i = 0;
 
        if (in_kb)
                i++;
 
-       while (num > 1000 * 1000ULL) {
+       while (num > 1000 * 1000ULL && (i < sizeof(suff) - 1)) {
                i++;
                num /= 1000;
        }