I was looking through the winpcap documentation and noticed this bit of code...
Code:
/* From tcptraceroute, convert a numeric IP address to a string */
#define IPTOSBUFFERS 12
char *iptos(u_long in)
{
static char output[IPTOSBUFFERS][3*4+3+1];
static short which;
u_char *p;
p = (u_char *)∈
which = (which + 1 == IPTOSBUFFERS ? 0 : which + 1);
_snprintf_s(output[which], sizeof(output[which]), sizeof(output[which]),"%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
return output[which];
}
local variable "which" is not initialized. Unless I'm missing something that's undefined behavior. Or is there some sort of trickery going on here that I'm not aware of? There's an evaluation of it yet that variable could contain anything during that first go around (or any after for that matter).