1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
Description: Fix statistics buffer size
Author: Syed Shahrukh Hussain <syed.shahrukh@ossrevival.org>
diff --git a/diskStats.cpp b/diskStats.cpp
index 7974247..46f347b 100644
--- a/diskStats.cpp
+++ b/diskStats.cpp
@@ -130,10 +130,10 @@ inline string renderDiskStat(bool perSecond, bool showTotals, bool showSectors,
inline string renderDiskStat(bool perSecond, bool showTotals, bool showSectors, const double &elapsed,
const struct diskStat_t &diskStat)
{
- char output[40]; bzero(output, 40);
+ char output[41]; bzero(output, 40);
const string rendered = renderDiskBytes(perSecond, showTotals, showSectors, elapsed, diskStat);
- snprintf(output, 39, "%-4s %-34s", diskStat.name.c_str(), rendered.c_str());
+ snprintf(output, 40, "%-4s %-34s", diskStat.name.c_str(), rendered.c_str());
return output;
}
diff --git a/rendercpupagestat.cpp b/rendercpupagestat.cpp
index f8b3a9e..7ddef9c 100644
--- a/rendercpupagestat.cpp
+++ b/rendercpupagestat.cpp
@@ -14,8 +14,8 @@ inline vector <string> renderCPUstat(bool perSecond, bool showTotals, const doub
char buf[64]; bzero(buf, 64);
string output;
if(name == "uptime:") {
- char fractionalSeconds[3];
- snprintf(fractionalSeconds, 2, "%2d", getFrac(cpuDiff / USER_HZ, 100));
+ char fractionalSeconds[4];
+ snprintf(fractionalSeconds, 3, "%2d", getFrac(cpuDiff / USER_HZ, 100));
output += time_rel_abbrev( getCurTime() - (cpuDiff / double(USER_HZ)) );
} else {
if(timeDiff.weeks) {
|