From 94ec8d34db0ddef14b5446975663e5ff37e27b45 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 11 Oct 2012 22:47:13 +0200 Subject: [PATCH] Strip newline from incoming SPTPS requests. Most of the code doesn't care whether requests are terminated with a newline or not, except that when requests are forwarded, it is assumed they do not have one and a newline is added. When a node using SPTPS receives a request from another SPTPS-using node, and forwards it to a non-SPTPS-using node, this will result in two consecutive newlines, which the latter node will see as an empty, and thus invalid, request. --- src/meta.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/meta.c b/src/meta.c index dfb8392a..8786d7f8 100644 --- a/src/meta.c +++ b/src/meta.c @@ -109,6 +109,11 @@ bool receive_meta_sptps(void *handle, uint8_t type, const char *data, uint16_t l return true; } + /* Change newline to null byte, just like non-SPTPS requests */ + + if(data[length - 1] == '\n') + ((char *)data)[length - 1] = 0; + /* Otherwise we are waiting for a request */ return receive_request(c, data); -- 2.20.1