<p dir="ltr"><br>
On Nov 25, 2015 2:54 AM, "Hal Murray" <<a href="mailto:hmurray@megapathdsl.net">hmurray@megapathdsl.net</a>> wrote:<br>
><br>
><br>
> In ntpd/refclock_palisade.h<br>
> short rpt_cnt; /* TSIP packet length so far */<br>
> char rpt_buf[BMAX]; /* packet assembly buffer */<br>
><br>
> From ntpd/refclock_palisade.c<br>
> else if (up->rpt_cnt > BMAX)<br>
><br>
> That code is correct, but I would have used sizeof(rpt_buf) rather than BMAX.<br>
> With a little bit of poking around, you can figure out that rpt_buf is the<br>
> buffer. With BMAX, you have to go look in another file to see that it's the<br>
> size of the buffer.<br>
><br>
> But that gets:<br>
> ../ntpd/refclock_palisade.c:1415:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]<br>
> else if (up->rpt_cnt > sizeof(up->rpt_buf)) {<br>
><br>
> Both BMAX and sizeof work if I change the short to u_int.<br>
><br>
> So what is the type of sizeof, and what is the type of a literal constant? I expected them to be the same.</p>
<p dir="ltr">Use size_t. </p>
<p dir="ltr">> What is the best way to do this sort of thing?<br>
><br>
> Do I get a segfault if I botch something and get an underflow on a unsigned int and then use it as an index with a 64 bit pointer?<br>
><br>
><br>
> --<br>
> These are my opinions. I hate spam.<br>
><br>
><br>
><br>
> _______________________________________________<br>
> devel mailing list<br>
> <a href="mailto:devel@ntpsec.org">devel@ntpsec.org</a><br>
> <a href="http://lists.ntpsec.org/mailman/listinfo/devel">http://lists.ntpsec.org/mailman/listinfo/devel</a><br>
</p>