<div dir="ltr"><div><span style="font-family:monospace,monospace">[tmp]$ make CC=/usr/local/bin/gcc test<br>/usr/local/bin/gcc    -o test test.c<br>[tmp]$ ./test<br>Segmentation Fault (core dumped)</span><br><br></div>As you predicted.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 11 March 2015 at 14:50, Jeremy Laidman <span dir="ltr"><<a href="mailto:jlaidman@rebel-it.com.au" target="_blank">jlaidman@rebel-it.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yes, apparently, "(null)" is what GNU's printf outputs when asked to print a string pointer that is null.  The POSIX behaviour is not defined, and so in some systems, it dumps core rather than detecting the illegal string.<div><br></div><div>This bit of code demonstrates:</div><div><br></div><div><span class=""><div>#include <stdio.h></div><div>int main() {</div><div>        printf("test: %s\n",NULL);</div><div>}</div><div><br></div></span><div>On Linux and FreeBSD, this prints out "test: (null)" but on Solaris 10 this dumps core.</div><div><br></div><div>Fixing this is beyond my skill level.  But I would start looking at the functions errprintf() and dbgprintf() to see if NULL strings can be detected and prevented from being passed through to *printf.</div><div><br></div><div>But that might be somewhat tricky.  Alternatively, updating dump_tcp_services() to do the same, is probably a much simpler task, but doesn't safeguard any other code from the same fate.<span class="HOEnZb"><font color="#888888"><br></font></span></div></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>J</div><div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 11 March 2015 at 17:38, Jeremy Laidman <span dir="ltr"><<a href="mailto:jlaidman@rebel-it.com.au" target="_blank">jlaidman@rebel-it.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Even simpler:<div><br></div><div><div>#include <stdio.h></div><div>int main() {</div><div>        printf("test: %s\n",NULL);</div><div>}</div></div><div><br></div><div> </div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 11 March 2015 at 17:33, Jeremy Laidman <span dir="ltr"><<a href="mailto:jlaidman@rebel-it.com.au" target="_blank">jlaidman@rebel-it.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span><div class="gmail_extra"><div class="gmail_quote">On 11 March 2015 at 15:43, Vernon Everett <span dir="ltr"><<a href="mailto:everett.vernon@gmail.com" target="_blank">everett.vernon@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div>We have 4.3.12<br></div>And the command dumps core in the same way.<br></div></div></blockquote></div><br></div></span><div class="gmail_extra">That's good.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Can you try this out?  Plop into a text file, eg test.c, then "make test" and then "./test".</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">#include <stdio.h></div><div class="gmail_extra">#include <stdarg.h></div><div class="gmail_extra">void dbgprintf(const char *fmt, ...)<br></div><div class="gmail_extra">{</div><div class="gmail_extra">        va_list args;</div><div class="gmail_extra">        va_start(args, fmt);<br></div><div class="gmail_extra">        vfprintf(stdout, fmt, args);</div><div class="gmail_extra">        va_end(args);</div><div class="gmail_extra">        fflush(stdout);</div><div class="gmail_extra">}</div><div class="gmail_extra">int main() {<br></div><div class="gmail_extra">        dbgprintf("test: %s\n",NULL);</div><div class="gmail_extra">}</div><div><br></div><div>This is the essence of the Xymon code that prints the empty send/expect strings.  But I've pared away all of the Xymon code to leave just the call to vprintf() and whatever is needed to make it run.</div><div><br></div><div>On my systems I get the following output:</div><div><br></div><div>test: (null)</div><div><br></div><div>I'm guessing on your system you'll get a core dump.  If so, it would suggest a difference in implementations of the standard library functions.  If that's the case, we simply (!) need to catch the attempts to print NULL pointers, and substitute our own "(null)" string.</div><div><br></div><div>Indeed, I just tested this on a Solaris system and it dumped core.  On Linux and FreeBSD systems, it printed "(null)".</div><span><font color="#888888"><div><br></div><div>J</div><div><br></div></font></span></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><span>"Accept the challenges so that you can feel the exhilaration of victory"</span><div><span>- General George Patton</span></div></div>
</div>