[Pkg-nagios-devel] Bug#479061: nagios3: dereference NULL pointer when a check command returns no output

Stephane Chazelas stephane at artesyncp.com
Fri May 2 13:43:50 UTC 2008


Package: nagios3
Version: 3.0.1-1
Severity: normal


If a "check" command returns no output at all, you see the
output being "(null)" with the glibc and you would get a SEGV
with other libc's.

This is because of:

checks.c

2975         /* initialize dynamic buffer for storing plugin output */
2976         dbuf_init(&checkresult_dbuf,dbuf_chunk);
[...]
3042                         /* get all lines of plugin output - escape newlines */
3043                         while(fgets(output_buffer,sizeof(output_buffer)-1,fp)){
3044                                 temp_buffer=escape_newlines(output_buffer);
3045                                 dbuf_strcat(&checkresult_dbuf,temp_buffer);
3046                                 my_free(temp_buffer);
3047                                 }
[...]
3079                                 fprintf(check_result_info.output_file_fp,"output=%s\n",checkresult_dbuf.buf);

There's no pass in the while loop because the output is empty.

dbuf_init is:

3510 int dbuf_init(dbuf *db, int chunk_size){
3511
3512         if(db==NULL)
3513                 return ERROR;
3514
3515         db->buf=NULL;
3516         db->used_size=0L;
3517         db->allocated_size=0L;
3518         db->chunk_size=chunk_size;
3519
3520         return OK;
3521         }

So, we get a fprintf %s of NULL in that case.

A possible fix would be to have dbuf_init allocate some space for buf, and set
db->buf[0] = '\0'


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.24.2
Locale: LANG=en_GB.ISO-8859-15, LC_CTYPE=en_GB.ISO-8859-15 (charmap=ISO-8859-15)
Shell: /bin/sh linked to /bin/bash

Versions of packages nagios3 depends on:
ii  libc6                  2.7-10            GNU C Library: Shared libraries
ii  libgd2-xpm             2.0.36~rc1~dfsg-2 GD Graphics Library version 2
ii  libglib2.0-0           2.16.3-2          The GLib library of C routines
ii  libjpeg62              6b-14             The Independent JPEG Group's JPEG 
ii  libperl5.8             5.8.8-12          Shared Perl library
ii  libpng12-0             1.2.26-1          PNG library - runtime
ii  nagios3-common         3.0.1-1           support files for nagios3
ii  perl                   5.8.8-12          Larry Wall's Practical Extraction 
ii  zlib1g                 1:1.2.3.3.dfsg-12 compression library - runtime

nagios3 recommends no packages.

-- no debconf information





More information about the Pkg-nagios-devel mailing list