Commit 4ffe9734 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Add safety check in fill_rtt_message.

parent dabc3f3d
...@@ -663,6 +663,8 @@ static int ...@@ -663,6 +663,8 @@ static int
fill_rtt_message(struct interface *ifp) fill_rtt_message(struct interface *ifp)
{ {
if(ifp->enable_timestamps && (ifp->buffered_hello >= 0)) { if(ifp->enable_timestamps && (ifp->buffered_hello >= 0)) {
if(ifp->sendbuf[ifp->buffered_hello + 8] == SUBTLV_PADN &&
ifp->sendbuf[ifp->buffered_hello + 9] == 4) {
unsigned int time; unsigned int time;
/* Change the type of sub-TLV. */ /* Change the type of sub-TLV. */
ifp->sendbuf[ifp->buffered_hello + 8] = SUBTLV_TIMESTAMP; ifp->sendbuf[ifp->buffered_hello + 8] = SUBTLV_TIMESTAMP;
...@@ -670,6 +672,12 @@ fill_rtt_message(struct interface *ifp) ...@@ -670,6 +672,12 @@ fill_rtt_message(struct interface *ifp)
time = time_us(now); time = time_us(now);
DO_HTONL(ifp->sendbuf + ifp->buffered_hello + 10, time); DO_HTONL(ifp->sendbuf + ifp->buffered_hello + 10, time);
return 1; return 1;
} else {
fprintf(stderr,
"No space left for timestamp sub-TLV "
"(this shouldn't happen)\n");
return -1;
}
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment