C?????е????????й?
???????????? ???????[ 2015/8/26 13:20:33 ] ????????.NET ???????????
????????
?????????κ???? 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 ?????????й???
??????????????????????λ?ò????????????
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11