Commit 024c17ae authored by Antonin Décimo's avatar Antonin Décimo Committed by Juliusz Chroboczek

Fix confusion between INDEX_LEN and NONCE_LEN when sending PC TLV.

parent ceb021fb
...@@ -1148,7 +1148,7 @@ static void ...@@ -1148,7 +1148,7 @@ static void
ensure_space(struct buffered *buf, struct interface *ifp, int space) ensure_space(struct buffered *buf, struct interface *ifp, int space)
{ {
if(ifp->key != NULL) if(ifp->key != NULL)
space += MAX_HMAC_SPACE + 6 + NONCE_LEN; space += MAX_HMAC_SPACE + 6 + INDEX_LEN;
if(buf->size - buf->len < space) if(buf->size - buf->len < space)
flushbuf(buf, ifp); flushbuf(buf, ifp);
} }
...@@ -1156,8 +1156,9 @@ ensure_space(struct buffered *buf, struct interface *ifp, int space) ...@@ -1156,8 +1156,9 @@ ensure_space(struct buffered *buf, struct interface *ifp, int space)
static void static void
start_message(struct buffered *buf, struct interface *ifp, int type, int len) start_message(struct buffered *buf, struct interface *ifp, int type, int len)
{ {
int space = int space = ifp->key == NULL
ifp->key == NULL ? len + 2 : len + 2 + MAX_HMAC_SPACE + 6 + NONCE_LEN; ? len + 2
: len + 2 + MAX_HMAC_SPACE + 6 + INDEX_LEN;
if(buf->size - buf->len < space) if(buf->size - buf->len < space)
flushbuf(buf, ifp); flushbuf(buf, ifp);
buf->buf[buf->len++] = type; buf->buf[buf->len++] = type;
...@@ -1204,7 +1205,7 @@ accumulate_bytes(struct buffered *buf, ...@@ -1204,7 +1205,7 @@ accumulate_bytes(struct buffered *buf,
int int
send_pc(struct buffered *buf, struct interface *ifp) send_pc(struct buffered *buf, struct interface *ifp)
{ {
int space = 2 + MAX_HMAC_SPACE + 6 + NONCE_LEN; int space = MAX_HMAC_SPACE + 6 + INDEX_LEN;
if(buf->size - buf->len < space) { if(buf->size - buf->len < space) {
fputs("send_pc: no space left to accumulate pc.\n", stderr); fputs("send_pc: no space left to accumulate pc.\n", stderr);
return -1; return -1;
......
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