Fix bogus "Invalid magic" message when socket connection is established (#988)

This commit is contained in:
Uwe Seimet 2022-11-16 10:01:51 +01:00 committed by GitHub
parent 4645e8c975
commit 8c5dcd2f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,8 +123,12 @@ PbCommand RascsiService::ReadCommand(CommandContext& context) const
// Read magic string
vector<byte> magic(6);
if (const size_t bytes_read = context.GetSerializer().ReadBytes(fd, magic);
bytes_read != magic.size() || memcmp(magic.data(), "RASCSI", magic.size())) {
const size_t bytes_read = context.GetSerializer().ReadBytes(fd, magic);
if (!bytes_read) {
return command;
}
if (bytes_read != magic.size() || memcmp(magic.data(), "RASCSI", magic.size())) {
throw io_exception("Invalid magic");
}