From 8b334e9c9187f4eb8bdbfde7644f82a66d30af00 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch
Date: Sat, 13 Oct 2018 04:08:09 +0200 Subject: Fix fcgi_muxer_send() Outgoing records were missing padding and the reserved field. --- demo-json-rpc-server.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/demo-json-rpc-server.c b/demo-json-rpc-server.c index 995e7e2..fa7f833 100644 --- a/demo-json-rpc-server.c +++ b/demo-json-rpc-server.c @@ -145,14 +145,18 @@ fcgi_muxer_send (struct fcgi_muxer *self, hard_assert (len <= UINT16_MAX); struct str message = str_make (); + static char zeroes[8]; + size_t padding = -len & 7; str_pack_u8 (&message, FCGI_VERSION_1); str_pack_u8 (&message, type); str_pack_u16 (&message, request_id); - str_pack_u16 (&message, len); // content length - str_pack_u8 (&message, 0); // padding length + str_pack_u16 (&message, len); // content length + str_pack_u8 (&message, padding); // padding length + str_pack_u8 (&message, 0); // reserved str_append_data (&message, data, len); + str_append_data (&message, zeroes, padding); // XXX: we should probably have another write_cb that assumes ownership self->write_cb (self->user_data, message.str, message.len); -- cgit v1.2.3-70-g09d2