cybersecurity · intermediate · ~15 min · safe pentest lab
Decode an LE32 value.
Decode a 32-bit little-endian integer from 4 bytes — the building block for parsing pcap and most binary file formats.
Implement unsigned read_le32(const unsigned char *b) that assembles a 32-bit value from the 4 bytes at b, where b[0] is the least significant byte.
b: a byte buffer of at least 4 bytes. The grader passes a fixed buffer.Returns unsigned: b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24).
b = 0x78 0x56 0x34 0x12
read_le32(b) -> 0x12345678
A byte buffer b of at least 4 bytes.
An unsigned: the 4 bytes assembled little-endian (b[0] least significant).
b[0] is the low byte. Cast to unsigned before shifting.
unsigned read_le32(const unsigned char *b) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.