From 866d8d1d0ab363aed7cadf27f95fd51572201b42 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 6 May 2021 14:34:31 +0200 Subject: [PATCH] - Fixed issues with mismatching Content-Length in replies causing extra bytes to spill over into the next message --- apps/restconf/restconf_main_native.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/restconf/restconf_main_native.c b/apps/restconf/restconf_main_native.c index a4b19cd8..52dd9edf 100644 --- a/apps/restconf/restconf_main_native.c +++ b/apps/restconf/restconf_main_native.c @@ -901,15 +901,15 @@ send_badrequest(clicon_handle h, } cprintf(cb, "HTTP/1.1 400 Bad Request\r\nConnection: close\r\n"); if (body){ - cprintf(cb, "Content-Type: %s\r\n", media); - cprintf(cb, "Content-Length: %lu\r\n", strlen(body)+2); + cprintf(cb, "Content-Type: %s\r\n", media); + cprintf(cb, "Content-Length: %lu\r\n", strlen(body)); } else cprintf(cb, "Content-Length: 0\r\n"); cprintf(cb, "\r\n"); if (body) cprintf(cb, "%s\r\n", body); - if (buf_write(cbuf_get(cb), cbuf_len(cb)+1, s, ssl) < 0) + if (buf_write(cbuf_get(cb), cbuf_len(cb), s, ssl) < 0) goto done; retval = 0; done: @@ -1021,7 +1021,7 @@ restconf_connection(int s, } } } - if (buf_write(cbuf_get(rc->rc_outp_buf), cbuf_len(rc->rc_outp_buf)+1, conn->sock, conn->ssl) < 0) + if (buf_write(cbuf_get(rc->rc_outp_buf), cbuf_len(rc->rc_outp_buf), conn->sock, conn->ssl) < 0) goto done; cvec_reset(rc->rc_outp_hdrs); /* Can be done in native_send_reply */ cbuf_reset(rc->rc_outp_buf);