From 522cd7f18bf1e4a024d6771186a0149c5ca8109c Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sat, 30 Mar 2013 19:34:23 -0400 Subject: 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/store.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bootchart/store.c') diff --git a/src/bootchart/store.c b/src/bootchart/store.c index 343365e612..b2652c8d93 100644 --- a/src/bootchart/store.c +++ b/src/bootchart/store.c @@ -114,7 +114,7 @@ static int pid_cmdline_strscpy(char *buffer, size_t buf_len, int pid) { void log_sample(int sample) { static int vmstat; static int schedstat; - char buf[4095]; + char buf[4096]; char key[256]; char val[256]; char rt[256]; -- cgit v1.2.3-54-g00ecf