...
Code Block |
---|
#include <stdlib.h> #include <stdio.h> int func(char *str, size_t size) { char *temp = str; /*str and temp reference same location */ size_t i; for (i = 0; i < size-1; i++) temp[i] += 32; free(temp); return 0; } int main(void) { size_t size = 5; char *str = malloc(size); strncpy(str,"ABCD",size); printf("%s\n",str); /* 1st printing of str */ func(str,size); return 0; } |
References
VU#623332, http://www.kb.cert.org/vuls/id/623332