News for hackers. Stuff that matters.
Re:Fuzzing ping(8) and finding a 24 year old bug by nandalism on Sunday December 11, 2022 @05:17AM (#33941913)
I believe there is a bug in the bug fix.

I've explained it here: https://blog.deckc.hair/2022-12-11-incorrect-bug-fix-for-24y...

In brief (cp[IPOPT_OLEN] - 1) is the delta, not (cp[IPOPT_OLEN]); according to the original code. (I don't pretend to know where the original -1 comes from).

This means that the IF-statement check is incorrect.

Re:Fuzzing ping(8) and finding a 24 year old bug by bdhcuidbebe on Sunday December 11, 2022 @07:00AM (#33942454)
It is interesting why you chose to write a blog article on a diff, without looking at it in context. What is your end game, lol.
Re:Fuzzing ping(8) and finding a 24 year old bug by nandalism on Sunday December 11, 2022 @09:40AM (#33943582)
:) I am glad to have enterained you.

My end game is to get people to write

  int const delta = (cp[IPOPT_OLEN] - 1);
instead of repeating expressions like this: (cp[IPOPT_OLEN] - 1) and adding variants elsewhere like this: cp[IPOPT_OLEN]. It's confusing and causes bugs. Naming things helps and costs nothing.
Re:Fuzzing ping(8) and finding a 24 year old bug by charcircuit on Sunday December 11, 2022 @05:58AM (#33942135)
There is no bug.

>delta is allowed to be zero, we make no progress (as in the original bug)

It's not zero progress because the for loop increments cp every iteration.

In the original bug delta = -1.

Re:Fuzzing ping(8) and finding a 24 year old bug by nandalism on Sunday December 11, 2022 @06:19AM (#33942246)
Thank you for the clarification. I did not look at the surrounding code.

However, my point still stands that extracting the complex expression as delta would have helped and possibly avoided the original bug.

  int const delta = (cp[IPOPT_OLEN] - 1);
Further proof is that the original author first commited a broken fix. Again this was caused by the confusion between delta and delta-1, which would have been clear had delta been explicitly named.

This sort of code is just begging to be misunderstood.

- if (cp[IPOPT_OLEN] > 0 && cp[IPOPT_OLEN] < hlen) {

+ if (cp[IPOPT_OLEN] > 0 && (cp[IPOPT_OLEN] - 1) <= hlen) {

Re:Fuzzing ping(8) and finding a 24 year old bug by charcircuit on Sunday December 11, 2022 @06:40AM (#33942355)
The "bug" is from assuming you are parsing a valid packet. The option length field is the length of the option legnth and option data combined. The minimum value it can have is 1 which is when the length of the option data is 0.

cp[IPOPT_OLEN] refers to the option length. Your delta variable is the length of the option data. The confusing part is that in most network protocols length fields do not count the size of the length number.