I currently develop a server application which has to receive serialized data from clients, deserialize it and finally process it. The serialized data is sent in form of an array of chars. My problem is that my application can be easily broken by sending invalid data to it. So I wanted to ask whether it’s possible to check a string(-stream) and see whether it’s good for (de-)serialization (e.g. whether it has a valid signature) before trying to get data from it.
By the way: as the title already says, my application uses boost.serialization.
Many thanks in advance 🙂
I assume you want to do a lightweight check, without requiring to read all data (in which case handling the exceptions is as efficient as it will get).
I just tested success with this simple function:
Here is a simple test harness that I used (manipulating the data in data.bin before deserialization to check for ‘bad streams’):