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

Add safety check in fill_rtt_message.

parent dabc3f3d
...@@ -663,13 +663,21 @@ static int ...@@ -663,13 +663,21 @@ 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)) {
unsigned int time; if(ifp->sendbuf[ifp->buffered_hello + 8] == SUBTLV_PADN &&
/* Change the type of sub-TLV. */ ifp->sendbuf[ifp->buffered_hello + 9] == 4) {
ifp->sendbuf[ifp->buffered_hello + 8] = SUBTLV_TIMESTAMP; unsigned int time;
gettime(&now); /* Change the type of sub-TLV. */
time = time_us(now); ifp->sendbuf[ifp->buffered_hello + 8] = SUBTLV_TIMESTAMP;
DO_HTONL(ifp->sendbuf + ifp->buffered_hello + 10, time); gettime(&now);
return 1; time = time_us(now);
DO_HTONL(ifp->sendbuf + ifp->buffered_hello + 10, time);
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