write socket ):
(int a =4) -> to binarybuffer with memcpy -> send
server side ( read socket ):
read -> binarybuffer ->copy to (int b) with memcpy.
the memcpy is unsafe.
and if a badguy send something else.
server crash because of memory leak.
how can safely serilize and deserlize a datatype in server ?
What you suggest?
memcpy definitely isn't unsafe because you have to determine the exact size of the data to copy
if I have a another data type that has 4 byte size and copy that into a int variable ? 🤔 what about this situation
When you read a socket you get the amount of read data so there is no trouble about that
no if the size is same but datatype is different. is it work ?
It is in the use case you said, it is your job to define properly the values accepted for your data type
Обсуждают сегодня