diff options
author | christos <christos@NetBSD.org> | 2006-05-01 23:02:03 +0000 |
---|---|---|
committer | christos <christos@NetBSD.org> | 2006-05-01 23:02:03 +0000 |
commit | cd345470a95846ccbaa57fd0f24536cf1877aed5 (patch) | |
tree | 2b91f6a753b7e1ff2bce2caa8c2e6f80f67ff06c | |
parent | da0e3598d35d5ed45c90f69cd33c70772faa928a (diff) | |
download | bsd-progress-cd345470a95846ccbaa57fd0f24536cf1877aed5.tar.gz bsd-progress-cd345470a95846ccbaa57fd0f24536cf1877aed5.tar.zst bsd-progress-cd345470a95846ccbaa57fd0f24536cf1877aed5.zip |
Coverity CID 1447: Avoid buffer overflow.
-rw-r--r-- | progressbar.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/progressbar.c b/progressbar.c index 4ee520b..0e779d0 100644 --- a/progressbar.c +++ b/progressbar.c @@ -1,4 +1,4 @@ -/* $NetBSD: progressbar.c,v 1.12 2006/05/01 23:00:33 christos Exp $ */ +/* $NetBSD: progressbar.c,v 1.13 2006/05/01 23:02:03 christos Exp $ */ /*- * Copyright (c) 1997-2005 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: progressbar.c,v 1.12 2006/05/01 23:00:33 christos Exp $"); +__RCSID("$NetBSD: progressbar.c,v 1.13 2006/05/01 23:02:03 christos Exp $"); #endif /* not lint */ /* @@ -336,6 +336,8 @@ ptransfer(int siginfo) for (i = 1; bytespersec >= 1024000 && i < sizeof(prefixes); i++) bytespersec >>= 10; + if (i == sizeof(prefixes)) + i--; len += snprintf(buf + len, BUFLEFT, "(" LLF ".%02d %cB/s)", (LLT)(bytespersec / 1024), (int)((bytespersec % 1024) * 100 / 1024), |