Skip to content
hoalvh
Go back

[NOTE] - Type Error

3 min read Edit page

Data Types & Ranges Cheat Sheet (C / Linux)

This table focuses on C programming on Linux architectures (GCC), highlighting system types critical for understanding Type Confusion, Integer Overflows, and Memory Corruption.

Data TypeSize (Bytes)
(32-bit / 64-bit)
Approximate RangeFormat SpecifierPwnable / Security Notes
BASIC INTEGERS
char / signed char1-128 to 127%c, %hhdWatch out for Sign Extension bugs when casting to int.
unsigned char10 to 255%c, %hhuUsed for raw bytes, buffers, and shellcode.
short (signed)2-32,768 to 32,767%hd
unsigned short20 to 65,535%huStandard size for Network Ports.
int (signed)4-2B to +2B%dInteger Overflow mostly happens here.
unsigned int40 to ~4.29B%u, %xLogic bug: -1 (signed) is interpreted as MAX_INT (unsigned).
long (signed)4 / 8Arch dependent%ldNote: On Windows 64-bit, long is still 4 bytes.
unsigned long4 / 8Arch dependent%lu, %lx
long long8Huge ($2^{63}$)%lld
FIXED WIDTH(<stdint.h>)Use for precise byte control in exploits
int8_t / uint8_t1Same as charPRId8
int16_t / uint16_t2Same as shortPRId16
int32_t / uint32_t4Same as intPRId32Common in binary file headers/structures.
int64_t / uint64_t8Same as long longPRId64
SYSTEM & POINTERSCritical for Heap/Stack Overflow
size_t (Unsigned)4 / 80 to MAX%zuUsed for malloc, strlen. Never negative.
ssize_t (Signed)4 / 8-1 to MAX%zdUsed for read/write. Can be negative (-1) to signal error.
void * (Pointer)4 / 8Memory Address%pSize changes based on CPU architecture.
intptr_t4 / 8Fits 1 pointer%pSafe type for pointer arithmetic (+/- addresses).
FLOATING POINT
float4~7 digits%f
double8~15 digits%lf

Edit page