aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-03-15 15:22:42 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2016-03-15 15:22:42 +0100
commite4de8c631644be5e96711462763bf16491dda54f (patch)
treef14deaa3c616ba45dedf2cef9bbf637b1fb095c2 /procps
parentfd5a2b7b0441495fa520cfc938818cd1555a8129 (diff)
downloadbusybox-e4de8c631644be5e96711462763bf16491dda54f.tar.gz
nmeter: fix a bug with unterminated varargs
function old new delta collect_mem 361 371 +10 collect_swp 116 120 +4 vrdval 168 170 +2 collect_thread_nr 63 65 +2 collect_int 121 123 +2 collect_if 205 207 +2 collect_fork 117 119 +2 collect_fd 79 81 +2 collect_ctx 117 119 +2 collect_cpu 621 623 +2 collect_blk 557 559 +2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 11/0 up/down: 32/0) Total: 32 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
-rw-r--r--procps/nmeter.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/procps/nmeter.c b/procps/nmeter.c
index 5d5b83b8d..0ce6842e7 100644
--- a/procps/nmeter.c
+++ b/procps/nmeter.c
@@ -235,6 +235,8 @@ static int vrdval(const char* p, const char* key,
strtoull(p, NULL, 10) :
read_after_slash(p);
indexnext = va_arg(arg_ptr, int);
+ if (!indexnext)
+ return 0;
}
while (*p > ' ') p++; // skip over value
indexline++;
@@ -395,7 +397,7 @@ static void FAST_FUNC collect_cpu(cpu_stat *s)
char *bar = s->bar;
int i;
- if (rdval(get_file(&proc_stat), "cpu ", data, 1, 2, 3, 4, 5, 6, 7)) {
+ if (rdval(get_file(&proc_stat), "cpu ", data, 1, 2, 3, 4, 5, 6, 7, 0)) {
put_question_marks(bar_sz);
return;
}
@@ -464,7 +466,7 @@ static void FAST_FUNC collect_int(int_stat *s)
ullong data[1];
ullong old;
- if (rdval(get_file(&proc_stat), "intr", data, s->no)) {
+ if (rdval(get_file(&proc_stat), "intr", data, s->no, 0)) {
put_question_marks(4);
return;
}
@@ -498,7 +500,7 @@ static void FAST_FUNC collect_ctx(ctx_stat *s)
ullong data[1];
ullong old;
- if (rdval(get_file(&proc_stat), "ctxt", data, 1)) {
+ if (rdval(get_file(&proc_stat), "ctxt", data, 1, 0)) {
put_question_marks(4);
return;
}
@@ -530,7 +532,7 @@ static void FAST_FUNC collect_blk(blk_stat *s)
if (is26) {
i = rdval_diskstats(get_file(&proc_diskstats), data);
} else {
- i = rdval(get_file(&proc_stat), s->lookfor, data, 1, 2);
+ i = rdval(get_file(&proc_stat), s->lookfor, data, 1, 2, 0);
// Linux 2.4 reports bio in Kbytes, convert to sectors:
data[0] *= 2;
data[1] *= 2;
@@ -568,7 +570,7 @@ static void FAST_FUNC collect_thread_nr(fork_stat *s UNUSED_PARAM)
{
ullong data[1];
- if (rdval_loadavg(get_file(&proc_loadavg), data, 4)) {
+ if (rdval_loadavg(get_file(&proc_loadavg), data, 4, 0)) {
put_question_marks(4);
return;
}
@@ -580,7 +582,7 @@ static void FAST_FUNC collect_fork(fork_stat *s)
ullong data[1];
ullong old;
- if (rdval(get_file(&proc_stat), "processes", data, 1)) {
+ if (rdval(get_file(&proc_stat), "processes", data, 1, 0)) {
put_question_marks(4);
return;
}
@@ -614,7 +616,7 @@ static void FAST_FUNC collect_if(if_stat *s)
ullong data[4];
int i;
- if (rdval(get_file(&proc_net_dev), s->device_colon, data, 1, 3, 9, 11)) {
+ if (rdval(get_file(&proc_net_dev), s->device_colon, data, 1, 3, 9, 11, 0)) {
put_question_marks(10);
return;
}
@@ -692,7 +694,7 @@ static void FAST_FUNC collect_mem(mem_stat *s)
ullong m_cached = 0;
ullong m_slab = 0;
- if (rdval(get_file(&proc_meminfo), "MemTotal:", &m_total, 1)) {
+ if (rdval(get_file(&proc_meminfo), "MemTotal:", &m_total, 1, 0)) {
put_question_marks(4);
return;
}
@@ -701,10 +703,10 @@ static void FAST_FUNC collect_mem(mem_stat *s)
return;
}
- if (rdval(proc_meminfo.file, "MemFree:", &m_free , 1)
- || rdval(proc_meminfo.file, "Buffers:", &m_bufs , 1)
- || rdval(proc_meminfo.file, "Cached:", &m_cached, 1)
- || rdval(proc_meminfo.file, "Slab:", &m_slab , 1)
+ if (rdval(proc_meminfo.file, "MemFree:", &m_free , 1, 0)
+ || rdval(proc_meminfo.file, "Buffers:", &m_bufs , 1, 0)
+ || rdval(proc_meminfo.file, "Cached:", &m_cached, 1, 0)
+ || rdval(proc_meminfo.file, "Slab:", &m_slab , 1, 0)
) {
put_question_marks(4);
return;
@@ -735,8 +737,8 @@ static void FAST_FUNC collect_swp(swp_stat *s UNUSED_PARAM)
{
ullong s_total[1];
ullong s_free[1];
- if (rdval(get_file(&proc_meminfo), "SwapTotal:", s_total, 1)
- || rdval(proc_meminfo.file, "SwapFree:" , s_free, 1)
+ if (rdval(get_file(&proc_meminfo), "SwapTotal:", s_total, 1, 0)
+ || rdval(proc_meminfo.file, "SwapFree:" , s_free, 1, 0)
) {
put_question_marks(4);
return;
@@ -759,7 +761,7 @@ static void FAST_FUNC collect_fd(fd_stat *s UNUSED_PARAM)
{
ullong data[2];
- if (rdval(get_file(&proc_sys_fs_filenr), "", data, 1, 2)) {
+ if (rdval(get_file(&proc_sys_fs_filenr), "", data, 1, 2, 0)) {
put_question_marks(4);
return;
}