From: Art Cancro Date: Sat, 26 Feb 2022 20:13:14 +0000 (-0500) Subject: Handle messages that are empty (or which appear empty to MSG4 because they consist... X-Git-Tag: v950~8 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=d4237cff951d6f2589f7ecfcc1861b874e53352e;p=citadel.git Handle messages that are empty (or which appear empty to MSG4 because they consist solely of a non-renderable attachment in Part 0) by delivering a null json instead of locking up. --- diff --git a/webcit-ng/ctdlclient.c b/webcit-ng/ctdlclient.c index a861e2af7..44daa3b55 100644 --- a/webcit-ng/ctdlclient.c +++ b/webcit-ng/ctdlclient.c @@ -77,7 +77,7 @@ StrBuf *ctdl_readtextmsg(struct ctdlsession *ctdl) { return NULL; } - while ((ctdl_readline(ctdl, buf, sizeof(buf)) >= 0) && (strcmp(buf, "000"))) { + while (ctdl_readline(ctdl, buf, sizeof(buf)), strcmp(buf, "000")) { StrBufAppendPrintf(sj, "%s\n", buf); } diff --git a/webcit-ng/forum_view.c b/webcit-ng/forum_view.c index 846c417b5..80320ec84 100644 --- a/webcit-ng/forum_view.c +++ b/webcit-ng/forum_view.c @@ -93,7 +93,12 @@ void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, striplt(content_type); } } - raw_msg = ctdl_readtextmsg(c); + if (!strcmp(buf, "000")) { // if we have an empty message, don't try to read further + raw_msg = NULL; + } + else { + raw_msg = ctdl_readtextmsg(c); + } } else { raw_msg = NULL;