From 10ac803a454da0e6130d544947fc826f0bb896d2 Mon Sep 17 00:00:00 2001 From: Houmgaor Date: Tue, 3 Mar 2026 18:23:45 +0100 Subject: [PATCH] fix(channelserver): correct ecdMagic constant byte order (#174) The constant used file-order bytes (0x6563641a) instead of the value produced by binary.LittleEndian.Uint32 (0x1A646365), causing loadRengokuBinary to reject every real ECD-encrypted rengoku_data.bin. The unit tests masked this because they round-tripped with the same wrong constant. --- server/channelserver/sys_channel_server.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/channelserver/sys_channel_server.go b/server/channelserver/sys_channel_server.go index 9448222af..b569d5dce 100644 --- a/server/channelserver/sys_channel_server.go +++ b/server/channelserver/sys_channel_server.go @@ -445,8 +445,9 @@ func (s *Server) Season() uint8 { return uint8(((TimeAdjusted().Unix() / secsPerDay) + sid) % 3) } -// ecdMagic is the first 4 bytes of an ECD-encrypted file (little-endian "ecd\x1a"). -const ecdMagic = uint32(0x6563641a) +// ecdMagic is the ECD magic as read by binary.LittleEndian.Uint32. +// On-disk bytes: 65 63 64 1A ("ecd\x1a"), LE-decoded: 0x1A646365. +const ecdMagic = uint32(0x1A646365) // loadRengokuBinary reads and validates rengoku_data.bin from binPath. // Returns the raw bytes on success, or nil if the file is missing or invalid. @@ -465,7 +466,7 @@ func loadRengokuBinary(binPath string, logger *zap.Logger) []byte { } if magic := binary.LittleEndian.Uint32(data[:4]); magic != ecdMagic { logger.Warn("rengoku_data.bin has invalid ECD magic, ignoring", - zap.String("expected", "0x6563641a"), + zap.String("expected", "0x1a646365"), zap.String("got", fmt.Sprintf("0x%08x", magic))) return nil }