|
|||||||||||
|
RE: Administrivia: List Announcement
From: Cameron Brown <cameron(at)greyzone.com>
Date: Tue May 13 2003 - 18:36:39 EDT If I supply an argv[1] of > 252 bytes, then byte 253 may (depending on many factors) overwrite the first byte of buf2. This is going to be (I think) part of the size of the malloc'd buf2. What interesting things can happen when you then free() an incorrectly-sized buf2 (or otherwise operate on buf2 if this were a real program) is something I am anxious to learn from others on this list! Cameron -----Original Message-----
We'll kick this off with the first challenge, which was devised by Aaron Adams: // vulndev-1.c
#include <stdio.h>
#define SIZE 252
int
int i;
char *p1, *p2;
char *buf1 = malloc(SIZE);
char *buf2 = malloc(SIZE);
if (argc != 3)
exit(1);
p1 = argv[1], p2 = argv[2];
strncpy(buf2, p2, SIZE);
for (i = 0; i <= SIZE && p1[i] != '\0'; i++)
buf1[i] = p1[i];
free(buf1);
free(buf2);
return 0;
}
Dave McKinney
keyID: BF919DD7
This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 14:07:39 EDT |
||||||||||
|
|||||||||||