5 ms·
char path[100]; snprintf(path, sizeof(path), "/proc/%d", pid); You're assuming the pid will fit in 93 bytes! The exact same mistake as `char pid[5];` Jokes
by alexvitkov 2y ago
char path[100];
snprintf(path, sizeof(path), "/proc/%d", pid);
You're assuming the pid will fit in 93 bytes! The exact same mistake as `char pid[5];`
Jokes aside, sometimes userspace deserves to be broken, and `char pid[5]` is IMO one of those cases. The fact that we treat integers as a scarce reusable resource is bad, and the fact that we now have a second-order process identifier to cover that up is worse.
- formerly_proven 2y agoFun fact that broken code was in the runtime used by a major Fortran compiler