~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OFF BY ONE vuln ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It happens when the coder incorrectly sets the limits of an array for (i=0; i<5; i++) -> loops 5 times for (i=0; i<=5; i++) -> loops 6 times <- off by one error FencePost error: If you build a fence 100 feet long with posts 10 feet apart, how many posts do you need? 10?? WRONG! <- Off by one error 11 <-- YES strncat() vuln code: ----------------------------------------------------------------------------- int foo (char *s) { char buf[15]; memset(buf, 0, sizeof(buf)); strncat(buf, s, sizeof(buf)); // Final parameter should be: sizeof(buf)-1 return(0); } ----------------------------------------------------------------------------- On some systems (little endian architectures in particular) this can result in the overwriting of the least significant byte of the *frame pointer*. This can cause an exploitable condition where an attacker can hijack the local variables for the calling routine. Rsrc: wikipedia