diff --git a/MUNGA_L4/L4NET.CPP b/MUNGA_L4/L4NET.CPP index 6716692..d87784d 100644 --- a/MUNGA_L4/L4NET.CPP +++ b/MUNGA_L4/L4NET.CPP @@ -214,7 +214,15 @@ L4NetworkManager::L4NetworkManager(): } networkEggNotationFile = new NotationFile(egg_name); Register_Object(networkEggNotationFile); - networkEggNotationFile->WriteFile("last.egg"); + // + // NOT last.egg. That name now belongs to the egg saved beside + // last.spl for playback, and this is something else entirely - a + // debug dump of whatever egg was just loaded. The two collided, and + // playback picking this one up as if it were a recording's companion + // read a host table of the wrong length out of the spool header, + // walked off the end of it, and corrupted the heap. + // + networkEggNotationFile->WriteFile("last-loaded.egg"); currentNetworkState = NormalState; ReceiveEggFileMessage egg_message(-1, 10, "local egg", 10); diff --git a/MUNGA_L4/L4SPLR.cpp b/MUNGA_L4/L4SPLR.cpp index df356e5..54a4f80 100644 --- a/MUNGA_L4/L4SPLR.cpp +++ b/MUNGA_L4/L4SPLR.cpp @@ -367,6 +367,39 @@ void } } + // + // Did the header end where the packets begin? + // + // The table above holds one pair per host named in the EGG, and the + // reader trusts the egg to have as many hosts as the spool was written + // with. Hand it a different egg and the count differs, the read pointer + // stops short of - or past - the first packet, and every packet after + // that is parsed from the middle of something else. The first symptom is + // a nonsense message length, and the second is a corrupted heap: exit + // 0xC0000374, no message, nothing in the log. + // + // A packet here should start with a plausible length. If it does not, + // the egg does not belong to this spool, and saying so is worth more + // than whatever the heap does next. + // + { + NetworkPacket *first = (NetworkPacket*) spool->GetPointer(); + int first_length = (int) first->messageData.messageLength; + + if (first_length < (int) sizeof(Receiver::Message) + || first_length > 65536 + || first_length > (int) spool->GetBytesRemaining()) + { + DEBUG_STREAM << "\n\nError - this egg does not belong to this spool." + << " The host table ran to the wrong length and the first packet" + << " reads as " << first_length << " bytes, which cannot be" + << " right. Play it back with the .egg that was saved beside" + << " it.\n" << std::flush; + PostQuitMessage(AbortExitCodeID); + return; + } + } + // // Now, just send the load message //