????????
?????????κ???? C ????????????????? C ????????????????????????????????????????й?????Щ????????????????????????????????????????й????Щ?????????????????η?壬????????????????????????????????????????????? C ????????е???????
?????????????????????????????????????????????????????????????????
??????????????????????????
????????????????????????????
???????????й???????
????????????????????????????????????С????????壬????????????????????????????
?????????????????
?????м?????????????????????????????????????????????????????????????????е?????????????????
????δ??????????
??????????У?p ????????? 10 ???????? 10 ??????????????????????? 1 ?????
????char *p = malloc ( 10 );
????? 1. ????????

????????????? p ?????????????γ?????????????????????????????????????в????????????p ???????????????δ???????????
?????????????????????? memset ?? malloc????????? calloc??
????char *p = malloc (10);
????memset(p??’’??10);
????????????????????γ?????? p ???????????????????????????? Null ??????????????????е???????????????????????
??????渲??
???????? p ????????? 10 ??????????????????γ????? p д????? 11 ?????????ò?????????????????????????????????λ??“???”??????????????????? q ???????檔

???????????? q ?????д?δ?????????????????????????????????????????????????????Щ???????????в???????????????????????????????????????????
????char *name = (char *) malloc(11);
????// Assign some value to name
????memcpy ( p??name??11);
????// Problem begins here
??????????У?memcpy ????????? 11 ?????д?? p????????????????? 10 ??????
?????????????????????????д??????????????????????????д???????????н?????????????£?memcpy ????????????????????
????????????
???????????? (overread) ?????????????????????????е????????????????????????????????????????????????????????
????char *ptr = (char *)malloc(10);
????char name[20] ;
????memcpy ( name??ptr??20);
????// Problem begins here
??????????У?memcpy ????????? ptr ??? 20 ?????????????????????? 10 ???????????2???????????
???????й?
???????й???????????????????????б????????Щ???????й????????
?????????????????????????????????????
????char *memoryArea = malloc(10);
????char *newArea = malloc(10);
???????????????? 4 ????????λ??????

????memoryArea ?? newArea ????????? 10 ????????????????????? 4 ?????????????????????????????????????……
????memoryArea = newArea;
????????????????????????????θ????????鷳??
??????????????????У?????????? memoryArea ?????? newArea ????????memoryArea ????????????λ???????????????????? 5 ????????????????????????λ??????á?????? 10 ?????????й???

??????????????????????λ?ò????????????