Skip to content

Commit

Permalink
Append a PC message if Babel-MAC is enabled.
Browse files Browse the repository at this point in the history
Don’t call `start_message()` since it may cause an infinite loop.
  • Loading branch information
MisterDA authored and jech committed May 30, 2021
1 parent 46fc7da commit af02039
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1199,18 +1199,23 @@ accumulate_bytes(struct buffered *buf,
int
send_pc(struct buffered *buf, struct interface *ifp)
{
int space = 2 + MAX_HMAC_SPACE + 6 + NONCE_LEN;
if(buf->size - buf->len < space) {
fputs("send_pc: no space left to accumulate pc.\n", stderr);
return -1;
}
if(ifp->pc == 0) {
int rc;
rc = read_random_bytes(ifp->index, INDEX_LEN);
if(rc < INDEX_LEN)
return -1;
}
start_message(buf, ifp, MESSAGE_PC, 4 + INDEX_LEN);
accumulate_byte(buf, MESSAGE_PC);
accumulate_byte(buf, 4 + INDEX_LEN);
accumulate_int(buf, ifp->pc);
accumulate_bytes(buf, ifp->index, INDEX_LEN);
end_message(buf, MESSAGE_PC, 4 + INDEX_LEN);
ifp->pc++;
return 1;
return 0;
}

void
Expand Down

0 comments on commit af02039

Please sign in to comment.