{"record":{"id":"7788d1e4797bf60d","repo":"pion/webrtc","slug":"expected-and-actual-checksum-do-not-match","errorCode":null,"errorMessage":"expected and actual checksum do not match","messagePattern":"expected and actual checksum do not match","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/media/oggreader/oggreader.go","lineNumber":31,"sourceCode":")\n\nconst (\n\tpageHeaderTypeBeginningOfStream = 0x02\n\tpageHeaderSignature             = \"OggS\"\n\n\tidPageBasePayloadLength = 19\n\tpageHeaderLen           = 27\n)\n\nvar (\n\terrNilStream                       = errors.New(\"stream is nil\")\n\terrBadIDPageSignature              = errors.New(\"bad header signature\")\n\terrBadOpusTagsSignature            = errors.New(\"bad opus tags signature\")\n\terrBadIDPageType                   = errors.New(\"wrong header, expected beginning of stream\")\n\terrBadIDPageLength                 = errors.New(\"payload for id page must be 19 bytes\")\n\terrBadIDPagePayloadSignature       = errors.New(\"bad payload signature\")\n\terrShortPageHeader                 = errors.New(\"not enough data for payload header\")\n\terrChecksumMismatch                = errors.New(\"expected and actual checksum do not match\")\n\terrUnsupportedChannelMappingFamily = errors.New(\"unsupported channel mapping family\")\n)\n\n// OggReader is used to read Ogg files and return page payloads.\ntype OggReader struct {\n\tstream               io.Reader\n\tbytesReadSuccesfully int64\n\tchecksumTable        *[256]uint32\n\tdoChecksum           bool\n}\n\n// OggHeader contains Opus codec metadata parsed from an Opus ID page.\n// This header is extracted from an Ogg page payload that starts with the OpusHead\n// signature (the first page of an Opus stream in an Ogg container).\n//\n// Use OggPageHeader.OpusPacketType() to classify a page payload as OpusHead,\n// and OggPageHeader.ParseOpusHeader() to parse the OpusHead payload.\n//","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/oggreader/oggreader.go#L13-L49","documentation":"errChecksumMismatch is returned by ParseNextPage when the CRC32 checksum computed over the Ogg page does not match the checksum stored in the page header (bytes 22-25, little-endian). Ogg pages carry a CRC to detect corruption, and this library validates it.","triggerScenarios":"ParseNextPage (oggreader.go:334) computes the page checksum and compares it to binary.LittleEndian.Uint32(header[22:26]); any bit corruption or wrong checksum field triggers it. Also asserted directly in tests.","commonSituations":"File corrupted on disk or during transfer, buggy custom page writer that fails to compute the Ogg CRC, byte-level edits to page payloads without recomputing checksums.","solutions":["Re-obtain the file/stream; verify integrity (checksum the download)","If you generate Ogg pages, compute the standard Ogg CRC32 (poly 0x04c11db7, init 0) over the full page with the checksum field zeroed","Check any code that mutates page bytes in place"],"exampleFix":"// before: writer leaves stale checksum after payload edit\npayload[5] = 0x01\n// after: recompute page CRC with zeroed field\nbinary.LittleEndian.PutUint32(header[22:26], 0)\ncrc := oggCRC(append(header, payload...))\nbinary.LittleEndian.PutUint32(header[22:26], crc)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"page, payload, err := reader.ParseNextPage()\nif errors.Is(err, oggreader.ErrChecksumMismatch) {\n    // page corrupted: log page offset, resync or re-fetch source\n}","preventionTips":["Verify transfer integrity (checksum/hash the file after download)","If you write Ogg pages, always compute the standard Ogg CRC","Avoid in-place edits of page bytes without recomputing checksums"],"tags":["ogg","checksum","corruption","crc"],"backgroundTag":"checksum-mismatch","analyzedSha":"8c25dc09fa9e7c09aac4309ead88093d760432b0","analyzedAt":"2026-09-03T21:56:56.182Z","contentChangedAt":"2026-09-03T21:56:56.182Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}