
Heap Buffer Overflows: Causes, Detection and Prevention
A heap buffer overflow writes past a malloc block into the next chunk. Learn the common causes in C, how AddressSanitizer and Valgrind find them, and fixes.
Everything you need to level up your coding skills.

A heap buffer overflow writes past a malloc block into the next chunk. Learn the common causes in C, how AddressSanitizer and Valgrind find them, and fixes.

strerror_r has two incompatible signatures in glibc. Learn which one you get, how to write code that works with both, and how strerror_l avoids the problem.

A stack canary is a secret value placed before the return address and checked before ret. See how GCC emits it, where glibc stores it, and what it misses.

A cheat sheet of the errno values you meet most on Linux, such as ENOENT, EACCES, EINTR and EAGAIN, with the cause, the reaction and when not to retry.

Replace strcpy, strcat and sprintf in C with snprintf, memcpy with a checked length, and strlcpy, and detect truncation instead of overflowing a buffer.

Check every system call result in C: the -1 convention, short reads and writes, EINTR retries and close errors, with working helpers for Linux and glibc 2.41.

A map of the XNU kernel behind macOS: Mach tasks and ports, the BSD layer, IOKit, system call entry, virtual memory, security layers, extensions and boot.

One byte too few for the terminating NUL is enough to corrupt memory. See the common off-by-one patterns in C strings and how to write them correctly.

Turn errno into a readable message with perror and strerror in C on Linux with glibc 2.41, and learn when each one fits.

A stack buffer overflow writes past a local array into the data next to it. See how it happens in C, what a canary does, and which habits prevent it.

errno is a per-thread integer that C library and system calls set on failure. Learn when it is valid and how to read it correctly with glibc 2.41.

A complete guide to Linux kernel modules: lifecycle, build, load, parameters, exported symbols, a working misc device, licensing, signing, DKMS and debugging.
We send one email when a new post is published. No spam.