| 61 | // Load the packet from disk. |
| 62 | |
| 63 | bool CreatorPacket::Load(DiskFile *diskfile, u64 offset, PACKET_HEADER &header) |
| 64 | { |
| 65 | // Is the packet long enough |
| 66 | if (header.length <= sizeof(CREATORPACKET)) |
| 67 | { |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | // Is the packet too large (what is the longest reasonable creator description) |
| 72 | if (header.length - sizeof(CREATORPACKET) > 100000) |
| 73 | { |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | // Allocate the packet (with a little extra so we will have NULLs after the description) |
| 78 | CREATORPACKET *packet = (CREATORPACKET *)AllocatePacket((size_t)header.length, 4); |
| 79 | packet->header = header; |
| 80 | |
| 81 | // Load the rest of the packet from disk |
| 82 | return diskfile->Read(offset + sizeof(PACKET_HEADER), |
| 83 | packet->client, |
| 84 | (size_t)packet->header.length - sizeof(PACKET_HEADER)); |
| 85 | } |