News for hackers. Stuff that matters.
Re:Xkcd: Heartbleed Explanation by twic on Friday April 11, 2014 @07:22AM (#7572237)
The heartbeat extension was originally designed for DTLS, which is TLS over UDP. UDP datagrams don't arrive in a guaranteed order, or within any bounded time. If heartbeat used a fixed message, then if you sent a request and receive a response using DTLS, you would have no way of knowing if that response was a response to that request, or to some other request you sent ten minutes ago, or what.

Allowing the request and response to carry a payload lets you mark each request with a unique identifier, so that you can recognise the resulting responses.

It's basically like an HTTP cookie. In reverse.

I have no idea why the payload is variable-sized, rather than being (say) a fixed 32 bits. I would guess the specifier didn't want to bake in assumptions about how much space a unique identifier would need.

Re:Xkcd: Heartbleed Explanation by fulafel on Friday April 11, 2014 @09:42AM (#7572746)
> I have no idea why the payload is variable-sized

For DTLS path MTU discovery (according to the heartbeat extension RFC).

Re:Xkcd: Heartbleed Explanation by EvanAnderson on Friday April 11, 2014 @11:36AM (#7573496)
That could have been accomplished with a fixed-length payload and variable-length padding, though.
Re:Xkcd: Heartbleed Explanation by nollidge on Friday April 11, 2014 @09:25AM (#7572675)
I'm probably missing something, but if it's going to be of variable size, why not just a null-terminated string? Why does the size itself need to be specified along with the string?

EDIT: Nevermind, this thread [0] has more discussion about it.

[0] https://news.ycombinator.com/item?id=7572081

Re:Xkcd: Heartbleed Explanation by masklinn on Friday April 11, 2014 @07:36AM (#7572288)
> I would guess the specifier didn't want to bake in assumptions about how much space a unique identifier would need.

Yep, although an up-to-64KB buffer seems like overkill you'd get a guy getting by on a byte, while the other one has a distributed system and wants UUID or something

Re:Xkcd: Heartbleed Explanation by priomsrb on Friday April 11, 2014 @07:37AM (#7572294)
Makes sense. But 64k of data seems oddly large just to ID a message.
Re:Xkcd: Heartbleed Explanation by tedchs on Friday April 11, 2014 @11:36AM (#7573494)
64k is the max value of a 2-byte unsigned int, as 2^16 - 1 = 65535; is that the size of the length prefix?
Re:Xkcd: Heartbleed Explanation by stackcollision on Friday April 11, 2014 @03:49PM (#7575162)
I looked at the code and I'm pretty sure I saw that the payload size variable was a long int, so I was confused by this too.