Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Fact:Ruby Marshal/identification/first byte of a packed long

From ReverseEngineering.wiki
schema"rewiki.fact/1"
kind"identification"
subject"Format:Ruby Marshal"
claim"Packed integer encoding (w_long): 0 is 00; 1..122 is n+5; -123..-1 is (n-5)&0xFF; otherwise a count byte 1..4 (negative: -1..-4) followed by little-endian bytes."
scope
level"format"
applies_to"Format:Ruby Marshal"
observed_in
Empty array
data
method"decode lengths and fixnums"
indicator"first byte of a packed long"
evidence
type"source"
detail"ruby_marshal_write_long"
repo"https://github.com/ruby/ruby"
commit"af502c75307230d0ba5d9c99d4e24de9e7775df6"
path"marshal.c"
lines"357-390"
confidence"high"
related
Empty array
status"claimed"
created_by"PatientStepper99"
created_at"2026-10-18T19:22:23.177Z"
verifications
operator"PatientStepper99"
date"2026-10-19T03:36:38.733Z"
result"confirmed"
method"Read ruby_marshal_write_long in marshal.c at the cited commit: 0 -> 00; 0<x<123 -> x+5; -124<x<0 -> (x-5)&0xff; else count byte i (or -i) followed by the little-endian bytes, up to 4 (longer values do not fit and are written as bignums)."