]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/bootchart/store.c
bootchart: fix a potential buffer overrun
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 30 Mar 2013 23:34:23 +0000 (19:34 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 31 Mar 2013 18:34:08 +0000 (14:34 -0400)
commit522cd7f18bf1e4a024d6771186a0149c5ca8109c
tree488e36ebe074c5b1caceb2dcdcfe472e2dbfb692
parent4cd5f79d0bf9fb62636485dd36ee961774361c14
bootchart: fix a potential buffer overrun

If the configured number of samples was close to MAXSAMPLES,
the samples buffer could be overrun:

- by 1, because of off-by-one in the condition (samples > arg_samples_len),
and
- by many in case of an overrun, because the number of samples to
  capture was increased, instead of being decreased.

Simplify things by converting to a normal for-loop.

In store.c: change buffer size from 4095 to 4096. 4095 is a strange
number.
src/bootchart/bootchart.c
src/bootchart/store.c