Hi,<br><br>this will probably work, but won't it create a problem if
sizeof(input) < MAX_INPUT_BUFFER? Probably my solution has that
problem as well ...<br>Maybe we should use strlcpy here:<br>
<br>strlcpy(input_buffer2,input<div id="mb_2">,MAX_INPUT_BUFFER-1);<br><span class="sg"><br><br>Franky</span></div><br><br><div><span class="gmail_quote">On 6/19/08, <b class="gmail_sendername">Thomas Guyot-Sionnest</b> <<a href="mailto:dermoth@aei.ca">dermoth@aei.ca</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
-----BEGIN PGP SIGNED MESSAGE-----<br> Hash: SHA1<br> <br><br> On 19/06/08 07:46 AM, Franky Van Liedekerke wrote:<br> > Hi all,<br> ><br> > I had some problems with history.cgi where it consistently coredumped on me.<br>
 > After some searching, it seems that history.c assumes that each line in<br> > nagios.log has a certain maximum lenght (MAX_INPUT_BUFFER) but some<br> > plugins write more info away there (like the check_oracle_health plugin<br>
 > in my case).<br> > But the issue is: when such a long line is found, history.c doesn't chop<br> > it off after MAX_INPUT_BUFFER characters and as such coredumps ...<br> > Solution: add the line<br> ><br>
 > input[MAX_INPUT_BUFFER]='\x0';<br> ><br> > at around line 551 in cgi/history.c (before the "strip(input);" line),<br> > so the code becomes:<br> ><br> >         printf("<P><DIV CLASS='logEntries'>\n");<br>
 ><br> >         while(1){<br> ><br> >                 free(input);<br> ><br> >                 if(use_lifo==TRUE){<br> >                         if((input=pop_lifo())==NULL)<br> >                                 break;<br>
 >                         }<br> >                 else{<br> >                         if((input=mmap_fgets(thefile))==NULL)<br> >                                 break;<br> >                     &nbs
 p;   }<br> ><br>
 >                 input[MAX_INPUT_BUFFER]='\x0';<br> >                 strip(input);<br> ><br> > This solves my problem for now, but I don't know if it is the correct<br> > solution of course ...<br>
 <br> <br>I don't have time to test, but it looks like the segfault is just a few<br> lines below:<br> <br> strcpy(input_buffer2,input);<br> <br> input_buffer2 has a static length of MAX_INPUT_BUFFER, so you should<br>
 rather use strncpy and limit to "MAX_INPUT_BUFFER-1" characters (so it<br> will be able to terminate it with a \0).<br> <br> Your fix will work just as well, but changing strcpy to strncpy is more<br> obvious and use of strcpy is discouraged for that exact reason.<br>
 <br> Thomas<br> -----BEGIN PGP SIGNATURE-----<br> Version: GnuPG v1.4.6 (GNU/Linux)<br> Comment: Using GnuPG with Mozilla - <a href="http://enigmail.mozdev.org">http://enigmail.mozdev.org</a><br> <br> iD8DBQFIWksC6dZ+Kt5BchYRAr50AKDHHDBPVizBG8rPGvs2eMYTtyWxVQCgqAvn<br>
 zF/jM6g9ph5x6nqt92WiScQ=<br> =Zyc7<br> -----END PGP SIGNATURE-----<br> <br> -------------------------------------------------------------------------<br> Check out the new SourceForge.net Marketplace.<br> It's the best place to buy or sell services for<br>
 just about anything Open Source.<br> <a href="http://sourceforge.net/services/buy/index.php">http://sourceforge.net/services/buy/index.php</a><br> _______________________________________________<br> Nagios-devel mailing list<br>
 <a href="mailto:Nagios-devel@lists.sourceforge.net">Nagios-devel@lists.sourceforge.net</a><br> <a href="https://lists.sourceforge.net/lists/listinfo/nagios-devel">https://lists.sourceforge.net/lists/listinfo/nagios-devel</a><br>
 <br> </blockquote></div><br>