Skip to content

Comment on Fixing a Buffer Overflow in Unix v4 Like It's 1973parent

Comments

The article specifically mentions this optimization as not working with the compiler at that time, hence the need for the separate index variable.

We will edit su.c to prevent the overflow by maintaining a counter, i, and verifying it against the buffer size during the read loop. I initially attempted a fix using pointer arithmetic, but the 1973 C compiler didn’t like it, while it didn’t refuse the syntax, the code had no effect. I settled on a simpler index-based check instead.

Your sibling comment mentions it.

There's no details.. why didn't it work? Maybe the author didn't write it correctly? No word on what the assembly output for it was...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.