summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/JSONRPCDispatcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/JSONRPCDispatcher.cpp')
-rw-r--r--clang-tools-extra/clangd/JSONRPCDispatcher.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/JSONRPCDispatcher.cpp b/clang-tools-extra/clangd/JSONRPCDispatcher.cpp
index 5e48a071094..0aa1f396a9e 100644
--- a/clang-tools-extra/clangd/JSONRPCDispatcher.cpp
+++ b/clang-tools-extra/clangd/JSONRPCDispatcher.cpp
@@ -196,6 +196,15 @@ void clangd::runLanguageServerLoop(std::istream &In, JSONOutput &Out,
}
}
+ // Guard against large messages. This is usually a bug in the client code
+ // and we don't want to crash downstream because of it.
+ if (ContentLength > 1 << 30) { // 1024M
+ In.ignore(ContentLength);
+ Out.log("Skipped overly large message of " + Twine(ContentLength) +
+ " bytes.\n");
+ continue;
+ }
+
if (ContentLength > 0) {
// Now read the JSON. Insert a trailing null byte as required by the YAML
// parser.
OpenPOWER on IntegriCloud