From 48a0b5c44bbfd6cb2ab9d0e9afe2aec75e991597 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 28 Sep 2016 17:16:49 +0200 Subject: Fix bound checking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/plugins/df | 2 +- examples/plugins/mem | 2 +- examples/plugins/network | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/plugins') diff --git a/examples/plugins/df b/examples/plugins/df index d6c257f..5b3926b 100644 --- a/examples/plugins/df +++ b/examples/plugins/df @@ -58,7 +58,7 @@ def redraw(): def u(b): unit = 0 units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'] - while (unit < len(units)) and (b >= 1024): + while (unit + 1 < len(units)) and (b >= 1024): b /= 1024 unit += 1 return '%7.2f%s' % (b, units[unit]) diff --git a/examples/plugins/mem b/examples/plugins/mem index 01f7e9c..518b21d 100644 --- a/examples/plugins/mem +++ b/examples/plugins/mem @@ -49,7 +49,7 @@ def redraw(): def u(b): unit = 0 units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB'] - while (unit < len(units)) and (b >= 1024): + while (unit + 1 < len(units)) and (b >= 1024): b /= 1024 unit += 1 return '%.0f%s' % (b, units[unit]) diff --git a/examples/plugins/network b/examples/plugins/network index cdcbcee..0431bb9 100644 --- a/examples/plugins/network +++ b/examples/plugins/network @@ -79,7 +79,7 @@ def redraw(): def u(b): unit = 0 units = ['', 'K', 'M', 'G', 'T', 'P', 'E'] - while (unit < len(units)) and (b >= 1024): + while (unit + 1 < len(units)) and (b >= 1024): b /= 1024 unit += 1 return '%.0f%s' % (b, units[unit]) -- cgit v1.2.3-70-g09d2