cn-uofbasel / ccn-lite

CCN-lite, a lightweight implementation of the CCNx protocol and its variations
ISC License
74 stars 63 forks source link

ccn-lite-fetch memory corrupion #386

Open MahdiBaghbani opened 3 years ago

MahdiBaghbani commented 3 years ago

freeing a pointer causes memory corruption in ccn-lite-fetch

here in code: https://github.com/cn-uofbasel/ccn-lite/blob/da0d9de8d82349dff845acc62d37242dd09b3d3d/src/ccnl-utils/src/ccn-lite-fetch.c#L137-L141

assigning content and content length pointer values from pkt to external pointers and then freeing the pkt itself also removes the pointers pointing to the memory location and causes memory corruption and garbage output from any write operation: https://github.com/cn-uofbasel/ccn-lite/blob/da0d9de8d82349dff845acc62d37242dd09b3d3d/src/ccnl-utils/src/ccn-lite-fetch.c#L360

possible solution would be passing the pkt itself out of function and free it after write function