diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-03-15 15:22:42 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-03-15 15:22:42 +0100 |
commit | e4de8c631644be5e96711462763bf16491dda54f (patch) | |
tree | f14deaa3c616ba45dedf2cef9bbf637b1fb095c2 | |
parent | fd5a2b7b0441495fa520cfc938818cd1555a8129 (diff) | |
download | busybox-w32-e4de8c631644be5e96711462763bf16491dda54f.tar.gz busybox-w32-e4de8c631644be5e96711462763bf16491dda54f.tar.bz2 busybox-w32-e4de8c631644be5e96711462763bf16491dda54f.zip |
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>
-rw-r--r-- | procps/nmeter.c | 32 |
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, | |||
235 | strtoull(p, NULL, 10) : | 235 | strtoull(p, NULL, 10) : |
236 | read_after_slash(p); | 236 | read_after_slash(p); |
237 | indexnext = va_arg(arg_ptr, int); | 237 | indexnext = va_arg(arg_ptr, int); |
238 | if (!indexnext) | ||
239 | return 0; | ||
238 | } | 240 | } |
239 | while (*p > ' ') p++; // skip over value | 241 | while (*p > ' ') p++; // skip over value |
240 | indexline++; | 242 | indexline++; |
@@ -395,7 +397,7 @@ static void FAST_FUNC collect_cpu(cpu_stat *s) | |||
395 | char *bar = s->bar; | 397 | char *bar = s->bar; |
396 | int i; | 398 | int i; |
397 | 399 | ||
398 | if (rdval(get_file(&proc_stat), "cpu ", data, 1, 2, 3, 4, 5, 6, 7)) { | 400 | if (rdval(get_file(&proc_stat), "cpu ", data, 1, 2, 3, 4, 5, 6, 7, 0)) { |
399 | put_question_marks(bar_sz); | 401 | put_question_marks(bar_sz); |
400 | return; | 402 | return; |
401 | } | 403 | } |
@@ -464,7 +466,7 @@ static void FAST_FUNC collect_int(int_stat *s) | |||
464 | ullong data[1]; | 466 | ullong data[1]; |
465 | ullong old; | 467 | ullong old; |
466 | 468 | ||
467 | if (rdval(get_file(&proc_stat), "intr", data, s->no)) { | 469 | if (rdval(get_file(&proc_stat), "intr", data, s->no, 0)) { |
468 | put_question_marks(4); | 470 | put_question_marks(4); |
469 | return; | 471 | return; |
470 | } | 472 | } |
@@ -498,7 +500,7 @@ static void FAST_FUNC collect_ctx(ctx_stat *s) | |||
498 | ullong data[1]; | 500 | ullong data[1]; |
499 | ullong old; | 501 | ullong old; |
500 | 502 | ||
501 | if (rdval(get_file(&proc_stat), "ctxt", data, 1)) { | 503 | if (rdval(get_file(&proc_stat), "ctxt", data, 1, 0)) { |
502 | put_question_marks(4); | 504 | put_question_marks(4); |
503 | return; | 505 | return; |
504 | } | 506 | } |
@@ -530,7 +532,7 @@ static void FAST_FUNC collect_blk(blk_stat *s) | |||
530 | if (is26) { | 532 | if (is26) { |
531 | i = rdval_diskstats(get_file(&proc_diskstats), data); | 533 | i = rdval_diskstats(get_file(&proc_diskstats), data); |
532 | } else { | 534 | } else { |
533 | i = rdval(get_file(&proc_stat), s->lookfor, data, 1, 2); | 535 | i = rdval(get_file(&proc_stat), s->lookfor, data, 1, 2, 0); |
534 | // Linux 2.4 reports bio in Kbytes, convert to sectors: | 536 | // Linux 2.4 reports bio in Kbytes, convert to sectors: |
535 | data[0] *= 2; | 537 | data[0] *= 2; |
536 | data[1] *= 2; | 538 | data[1] *= 2; |
@@ -568,7 +570,7 @@ static void FAST_FUNC collect_thread_nr(fork_stat *s UNUSED_PARAM) | |||
568 | { | 570 | { |
569 | ullong data[1]; | 571 | ullong data[1]; |
570 | 572 | ||
571 | if (rdval_loadavg(get_file(&proc_loadavg), data, 4)) { | 573 | if (rdval_loadavg(get_file(&proc_loadavg), data, 4, 0)) { |
572 | put_question_marks(4); | 574 | put_question_marks(4); |
573 | return; | 575 | return; |
574 | } | 576 | } |
@@ -580,7 +582,7 @@ static void FAST_FUNC collect_fork(fork_stat *s) | |||
580 | ullong data[1]; | 582 | ullong data[1]; |
581 | ullong old; | 583 | ullong old; |
582 | 584 | ||
583 | if (rdval(get_file(&proc_stat), "processes", data, 1)) { | 585 | if (rdval(get_file(&proc_stat), "processes", data, 1, 0)) { |
584 | put_question_marks(4); | 586 | put_question_marks(4); |
585 | return; | 587 | return; |
586 | } | 588 | } |
@@ -614,7 +616,7 @@ static void FAST_FUNC collect_if(if_stat *s) | |||
614 | ullong data[4]; | 616 | ullong data[4]; |
615 | int i; | 617 | int i; |
616 | 618 | ||
617 | if (rdval(get_file(&proc_net_dev), s->device_colon, data, 1, 3, 9, 11)) { | 619 | if (rdval(get_file(&proc_net_dev), s->device_colon, data, 1, 3, 9, 11, 0)) { |
618 | put_question_marks(10); | 620 | put_question_marks(10); |
619 | return; | 621 | return; |
620 | } | 622 | } |
@@ -692,7 +694,7 @@ static void FAST_FUNC collect_mem(mem_stat *s) | |||
692 | ullong m_cached = 0; | 694 | ullong m_cached = 0; |
693 | ullong m_slab = 0; | 695 | ullong m_slab = 0; |
694 | 696 | ||
695 | if (rdval(get_file(&proc_meminfo), "MemTotal:", &m_total, 1)) { | 697 | if (rdval(get_file(&proc_meminfo), "MemTotal:", &m_total, 1, 0)) { |
696 | put_question_marks(4); | 698 | put_question_marks(4); |
697 | return; | 699 | return; |
698 | } | 700 | } |
@@ -701,10 +703,10 @@ static void FAST_FUNC collect_mem(mem_stat *s) | |||
701 | return; | 703 | return; |
702 | } | 704 | } |
703 | 705 | ||
704 | if (rdval(proc_meminfo.file, "MemFree:", &m_free , 1) | 706 | if (rdval(proc_meminfo.file, "MemFree:", &m_free , 1, 0) |
705 | || rdval(proc_meminfo.file, "Buffers:", &m_bufs , 1) | 707 | || rdval(proc_meminfo.file, "Buffers:", &m_bufs , 1, 0) |
706 | || rdval(proc_meminfo.file, "Cached:", &m_cached, 1) | 708 | || rdval(proc_meminfo.file, "Cached:", &m_cached, 1, 0) |
707 | || rdval(proc_meminfo.file, "Slab:", &m_slab , 1) | 709 | || rdval(proc_meminfo.file, "Slab:", &m_slab , 1, 0) |
708 | ) { | 710 | ) { |
709 | put_question_marks(4); | 711 | put_question_marks(4); |
710 | return; | 712 | return; |
@@ -735,8 +737,8 @@ static void FAST_FUNC collect_swp(swp_stat *s UNUSED_PARAM) | |||
735 | { | 737 | { |
736 | ullong s_total[1]; | 738 | ullong s_total[1]; |
737 | ullong s_free[1]; | 739 | ullong s_free[1]; |
738 | if (rdval(get_file(&proc_meminfo), "SwapTotal:", s_total, 1) | 740 | if (rdval(get_file(&proc_meminfo), "SwapTotal:", s_total, 1, 0) |
739 | || rdval(proc_meminfo.file, "SwapFree:" , s_free, 1) | 741 | || rdval(proc_meminfo.file, "SwapFree:" , s_free, 1, 0) |
740 | ) { | 742 | ) { |
741 | put_question_marks(4); | 743 | put_question_marks(4); |
742 | return; | 744 | return; |
@@ -759,7 +761,7 @@ static void FAST_FUNC collect_fd(fd_stat *s UNUSED_PARAM) | |||
759 | { | 761 | { |
760 | ullong data[2]; | 762 | ullong data[2]; |
761 | 763 | ||
762 | if (rdval(get_file(&proc_sys_fs_filenr), "", data, 1, 2)) { | 764 | if (rdval(get_file(&proc_sys_fs_filenr), "", data, 1, 2, 0)) { |
763 | put_question_marks(4); | 765 | put_question_marks(4); |
764 | return; | 766 | return; |
765 | } | 767 | } |