[PATCH] fix segfault when sending host notifications

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[PATCH] fix segfault when sending host notifications

Post by Guest »

This is a multi-part message in MIME format.
--------------040102030805020802040704
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

hi,

hacking around in Icinga Core, the patch on the nagios-exp.git
repository on git.op5.org for using local macros on the notifications
came up with a bug on the host notifications.
basically, a memset was missing in order to allocate memory before
accessing/freeing the macro struct. See over here
https://dev.icinga.org/issues/1703 and/or below. On Icinga GIT you will
recognize the commit already.


start gdb

~/nagios/nagios-exp $ sudo gdb base/nagios

(gdb) run /usr/local/nagios/etc/nagios.cfg
Starting program: nagios/nagios-exp/base/nagios
/usr/local/nagios/etc/nagios.cfg
[Thread debugging using libthread_db enabled]

Nagios Core 3.3.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community
Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 02-13-2011
License: GPL

Website: http://www.nagios.org
Nagios 3.3.1 starting... (PID=10221)
Local time is Wed Jul 13 17:47:18 CEST 2011
[New Thread 0x40a00940 (LWP 10224)]
[New Thread 0x41401940 (LWP 10225)]


send a custom host notification

# /usr/bin/printf "[1310543176]
SEND_CUSTOM_HOST_NOTIFICATION;localhost;2;nagiosadmin;foobar" >
/usr/local/nagios/var/rw/nagios.cmd


watch it die ...

ARGS: localhost;2;nagiosadmin;foobar

Program received signal SIGSEGV, Segmentation fault.
0x0000003fe247273e in free () from /lib64/libc.so.6

attached is a patch, which fixes this accordingly and applies cleanly to
nagios-exp HEAD.

Nagios 3.3.1 starting... (PID=13983)
Local time is Wed Jul 13 18:00:23 CEST 2011
[New Thread 0x40a00940 (LWP 13986)]
[New Thread 0x41401940 (LWP 13987)]
ARGS: localhost;2;nagiosadmin;foobar
Detaching after fork from child process 14060.

feel free to use the patch or introduce a proper solution :-)


kind regards,
Michael


backtrace.

(gdb) bt full
#0 0x0000003fe247273e in free () from /lib64/libc.so.6
No symbol table info available.
#1 0x000000000042fa91 in clear_volatile_macros_r (mac=0x7fffffffdf00) at
../common/macros.c:2824
this_customvariablesmember =
next_customvariablesmember =
x = 2
#2 0x0000000000439b99 in host_notification (hst=0x6b8440, type=99,
not_author=0x6b4d00 "nagiosadmin", not_data=0x6b5230 "foobar",
options=2) at notifications.c:1041
temp_notification =
temp_contact =
current_time =
start_time = {tv_sec = 1310572223, tv_usec = 700585}
end_time = {tv_sec = 7012920, tv_usec = 7}
escalated = 0
result =
contacts_notified =
increment_notification_number =
mac = {x = {0x0, 0x0, 0x20 , 0x0, 0x64000000
, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0xa , 0x5c ,
0xffffffff0000000a , 0x480b01
"s\n", 0x0, 0x25 ,
0x1 , 0x21 ,
0x100000001 ,
0x490ab8 "d\n", 0x0, 0x0, 0x3fe248d98f "\205\300\017\204\231\001", 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x1 , 0x0, 0x3000000018 , 0x7fffffffe380 "\300\352\340\302>",
0x801 , 0x9802f , 0x1 ,
0x81a4 , 0x0, 0x0, 0x8a3 , 0x1000 ,
0x10 , 0x4e1dbeb0 , 0x0,
0x4aef1ace , 0x0, 0x4aef1ace , 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x3fe27529e0 "", 0x3fe2520afb "/etc/localtime", 0xf , 0x69e890 "/etc/localtime",
0x3fe27535a0 "", 0x6bf13b "\342?", 0x3fe2474cde
"H\205\300H\211\305tJ\203=;\022.", 0xf <Address 0xf

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked