Переглянути джерело

In activitypub_post_handler(), drop input messages that are too big.

grunfink 2 тижнів тому
батько
коміт
dde11b15de
1 змінених файлів з 6 додано та 0 видалено
  1. 6 0
      activitypub.c

+ 6 - 0
activitypub.c

@@ -4110,6 +4110,12 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path,
         xs_str_in(i_ctype, "application/ld+json") == -1)
         xs_str_in(i_ctype, "application/ld+json") == -1)
         return 0;
         return 0;
 
 
+    if (p_size >= 100000) {
+        *body  = xs_str_new("too big");
+        *ctype = "text/plain";
+        return HTTP_STATUS_BAD_REQUEST;
+    }
+
     /* decode the message */
     /* decode the message */
     xs *msg = xs_json_loads(payload);
     xs *msg = xs_json_loads(payload);
     const char *id = xs_dict_get(msg, "id");
     const char *id = xs_dict_get(msg, "id");