增强序列化:查看流是否“良好”
我目前开发一个服务器应用程序,它必须从客户端接收序列化数据,反序列化它并最终处理它。序列化数据以字符数组的形式发送。我的问题是,我的应用程序很容易通过向其发送无效数据而被破坏。所以我想问是否可以在尝试从中获取数据之前检查字符串(-stream)并查看它是否有利于(反)序列化(例如,它是否具有有效的签名)。
顺便说一句:正如标题所说,我的应用程序使用 boost.serialization。
非常感谢提前:)
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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您想要进行轻量级检查,而不需要读取所有数据(在这种情况下,处理异常是尽可能高效的)。
我刚刚使用这个简单的函数测试了成功:
这是我使用的一个简单的测试工具(在反序列化之前操作 data.bin 中的数据以检查“坏流”):
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'):