mirror of
https://git.wownero.com/wownero/wownero-puddle.git
synced 2024-08-15 01:03:20 +00:00
fail early on long input
This commit is contained in:
parent
2d23056e24
commit
2b36c6090c
1 changed files with 7 additions and 7 deletions
14
src/pool.c
14
src/pool.c
|
@ -1867,7 +1867,6 @@ client_on_submit(json_object *message, client_t *client)
|
||||||
long int li = strtol(nptr, &endptr, 16);
|
long int li = strtol(nptr, &endptr, 16);
|
||||||
if (errno != 0 || nptr == endptr)
|
if (errno != 0 || nptr == endptr)
|
||||||
return send_validation_error(client, "nonce not a long int");
|
return send_validation_error(client, "nonce not a long int");
|
||||||
errno = 0;
|
|
||||||
const uint32_t nonce = ntohl(li);
|
const uint32_t nonce = ntohl(li);
|
||||||
|
|
||||||
json_object *result_ob = json_object_object_get(params, "result");
|
json_object *result_ob = json_object_object_get(params, "result");
|
||||||
|
@ -2107,6 +2106,13 @@ client_on_read(struct bufferevent *bev, void *ctx)
|
||||||
input = bufferevent_get_input(bev);
|
input = bufferevent_get_input(bev);
|
||||||
output = bufferevent_get_output(bev);
|
output = bufferevent_get_output(bev);
|
||||||
|
|
||||||
|
if (evbuffer_get_length(input) >= MAX_LINE)
|
||||||
|
{
|
||||||
|
const char *too_long = "Message too long\n";
|
||||||
|
evbuffer_add(output, too_long, strlen(too_long));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while ((line = evbuffer_readln(input, &n, EVBUFFER_EOL_LF)))
|
while ((line = evbuffer_readln(input, &n, EVBUFFER_EOL_LF)))
|
||||||
{
|
{
|
||||||
json_object *message = json_tokener_parse(line);
|
json_object *message = json_tokener_parse(line);
|
||||||
|
@ -2142,12 +2148,6 @@ client_on_read(struct bufferevent *bev, void *ctx)
|
||||||
json_object_put(message);
|
json_object_put(message);
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evbuffer_get_length(input) >= MAX_LINE)
|
|
||||||
{
|
|
||||||
const char *too_long = "Message too long\n";
|
|
||||||
evbuffer_add(output, too_long, strlen(too_long));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue