]>
Commit | Line | Data |
---|---|---|
bb330e25 AF |
1 | commit 3cb26316b45b23dc5cfecbafdc489b28c3a52029 |
2 | Author: Siddhesh Poyarekar <siddhesh@redhat.com> | |
3 | Date: Thu Jan 29 10:30:09 2015 +0530 | |
4 | ||
5 | Initialize nscd stats data [BZ #17892] | |
6 | ||
7 | The padding bytes in the statsdata struct are not initialized, due to | |
8 | which valgrind throws a warning: | |
9 | ||
10 | ==11384== Memcheck, a memory error detector | |
11 | ==11384== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. | |
12 | ==11384== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info | |
13 | ==11384== Command: nscd -d | |
14 | ==11384== | |
15 | Fri 25 Apr 2014 10:34:53 AM CEST - 11384: handle_request: request received (Version = 2) from PID 11396 | |
16 | Fri 25 Apr 2014 10:34:53 AM CEST - 11384: GETSTAT | |
17 | ==11384== Thread 6: | |
18 | ==11384== Syscall param socketcall.sendto(msg) points to uninitialised byte(s) | |
19 | ==11384== at 0x4E4ACDC: send (in /lib64/libpthread-2.12.so) | |
20 | ==11384== by 0x11AF6B: send_stats (in /usr/sbin/nscd) | |
21 | ==11384== by 0x112F75: nscd_run_worker (in /usr/sbin/nscd) | |
22 | ==11384== by 0x4E439D0: start_thread (in /lib64/libpthread-2.12.so) | |
23 | ==11384== by 0x599AB6C: clone (in /lib64/libc-2.12.so) | |
24 | ==11384== Address 0x15708395 is on thread 6's stack | |
25 | ||
26 | Fix the warning by initializing the structure. | |
27 | ||
28 | diff --git a/nscd/nscd_stat.c b/nscd/nscd_stat.c | |
29 | index 0f1f3c0..7aaa21b 100644 | |
30 | --- a/nscd/nscd_stat.c | |
31 | +++ b/nscd/nscd_stat.c | |
32 | @@ -94,6 +94,8 @@ send_stats (int fd, struct database_dyn dbs[lastdb]) | |
33 | struct statdata data; | |
34 | int cnt; | |
35 | ||
36 | + memset (&data, 0, sizeof (data)); | |
37 | + | |
38 | memcpy (data.version, compilation, sizeof (compilation)); | |
39 | data.debug_level = debug_level; | |
40 | data.runtime = time (NULL) - start_time; |