From e069864c4d31baf902bb11762e6839b61a949038 Mon Sep 17 00:00:00 2001 From: Lev Babiev Date: Sat, 22 Jun 2024 18:10:47 +0100 Subject: [PATCH] misc: never decrement len to negative in recv_json --- src/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc.c b/src/misc.c index 40a8e7c..1b2be2f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -52,7 +52,7 @@ json_object *recv_json ( gint sock, gssize len ) { json = json_tokener_parse_ex(tok, buf, rlen); if(len>0) - len-=rlen; + len-=MIN(rlen, MIN(len, bufsize)); } json_tokener_free(tok);