commit 797acb6363c37e3f2afb87ce0b76773de1f95613
parent 1eb206600d47b3eb1aadaaa4090f0a4c8d19077b
Author: William Casarin <jb55@jb55.com>
Date: Sat, 22 Jan 2022 12:47:20 -0800
alloc enough space for the encrypted and decrypted msg
Diffstat:
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/error.h b/error.h
@@ -13,7 +13,7 @@ struct errors {
int enabled;
};
-#define note_error(errs, fmt, ...) note_error_(errs, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__)
+#define note_error(errs, fmt, ...) note_error_(errs, "%s:%s:%d: " fmt, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__)
static inline int cursor_push_error(struct cursor *cur, struct error *err)
{
diff --git a/lnsocket.c b/lnsocket.c
@@ -27,7 +27,7 @@
#define array_len(x) (sizeof(x)/sizeof(x[0]))
-#define MSGBUF_MEM 65536
+#define MSGBUF_MEM (65536*2)
#define ERROR_MEM 4096
int push_error(struct lnsocket *lnsocket, const char *err);
@@ -200,7 +200,11 @@ int lnsocket_read(struct lnsocket *ln, unsigned char **buf, unsigned short *len)
return note_error(&ln->errs, "out of memory");
if (!cursor_slice(&ln->msgbuf, &dec, size))
- return note_error(&ln->errs, "out of memory");
+ return note_error(&ln->errs, "out of memory: %d + %d = %d > %d",
+ ln->msgbuf.end - ln->msgbuf.p, size,
+ ln->msgbuf.end - ln->msgbuf.p + size,
+ MSGBUF_MEM
+ );
if (!read_all(ln->socket, enc.p, enc.end - enc.start))
return note_error(&ln->errs, "Failed reading body: %s",