








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









Fall 2008
//integer promotionschar c1, c2, c3 result;c1 = 100;c2 = 90;c3 = -120;result = c1+c2+c3;// will work correctly (BAD)
//JPEG vulnerabilityvoid getcomment(unsigned int len, char *src) {
unsigned int size;size = len - 2;char cmment = (char *) malloc(size + 1);memcpy (comment, src, size); } read the value of len from JPG file and then getcomment.
// truncation errormain(argc, argv){
unsigned short int total;total = strlen(argv[1])+strlen(argv[2]);char *buf = malloc (total)strcpy(buf, argv[1]);strcat(buf, argv[2]); }
// truncation problem with conversionbool func(char * name, long cbBuf);
unsigned short bufSize = cbBuf;char *buf = (char *) malloc (bufSize);if buf {
memcpy ( buf, name, cbBuf);
//usage exploitvoid usage(char *p) {
char str[1024];snprintf(str, 1024, “Usage: %s
usage(argv[0]);
//variadic functionint avg(int first, …) {
int count = 0, sum = 0, i = first;va_list marker;va_start(marker, first);while (i != -1) {
sum += i; count++;i = va_arg(marker, int); } va_end(marker)returns (sum? (sum/count) : 0);} call - avg( 1, 5, 8, -1);
//stretchable bufferchar outbuf[512], buffer[512];sprintf(buffer, “Wrong Command: %.400s”, user);sprintf(outbuf, buffer);-> input %497\x3c\xd3\xff\xbf....[shellcode]
//simplestfunc(char *user){ printf(user);}attack1: %s%s%s%s%s%s…………
may crash
attack2: %08x, %08x, %08x, …………attack3: use %x a few times and then use %sattack4: \xdc\xf5\x42\x01%08x%08x%08x%08x%s (very tricky