Page 1 of 1

[Nagios-devel] BUG in history.cgi (+ fix)

Posted: Thu Jun 19, 2008 3:45 am
by Guest
------=_Part_1859_28867609.1213875964675
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi all,

I had some problems with history.cgi where it consistently coredumped on me.
After some searching, it seems that history.c assumes that each line in
nagios.log has a certain maximum lenght (MAX_INPUT_BUFFER) but some plugins
write more info away there (like the check_oracle_health plugin in my case).
But the issue is: when such a long line is found, history.c doesn't chop it
off after MAX_INPUT_BUFFER characters and as such coredumps ...
Solution: add the line

input[MAX_INPUT_BUFFER]='\x0';

at around line 551 in cgi/history.c (before the "strip(input);" line), so
the code becomes:

printf("\n");

while(1){

free(input);

if(use_lifo==TRUE){
if((input=pop_lifo())==NULL)
break;
}
else{
if((input=mmap_fgets(thefile))==NULL)
break;
}

input[MAX_INPUT_BUFFER]='\x0';
strip(input);

This solves my problem for now, but I don't know if it is the correct
solution of course ...

Franky

------=_Part_1859_28867609.1213875964675
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi all,I had some problems with history.cgi where it consistently coredumped on me.After some searching, it seems that history.c assumes that each line in nagios.log has a certain maximum lenght (MAX_INPUT_BUFFER) but some plugins write more info away there (like the check_oracle_health plugin in my case).
But the issue is: when such a long line is found, history.c doesn't chop it off after MAX_INPUT_BUFFER characters and as such coredumps ...Solution: add the line input[MAX_INPUT_BUFFER]='\x0';
at around line 551 in cgi/history.c (before the "strip(input);" line), so the code becomes:        printf("<P><DIV CLASS='logEntries'>\n");        while(1){                free(input);
                if(use_lifo==TRUE){                        if((input=pop_lifo())==NULL)                                break;                        }                else{                        if((input=mmap_fgets(thefile))==NULL)
                                break;                        }                input[MAX_INPUT_BUFFER]='\x0';                strip(input);This solves my problem for now, but I don't know if it is the correct solution of course ...
Franky

------=_Part_1859_28867609.1213875964675--





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