mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
peer_failed: use towire_errorfmtv() which doesn't add nul terminator.
This code was actually wrong. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
7865b4a679
commit
e34ec8da2d
@ -58,7 +58,8 @@ CLOSINGD_COMMON_OBJS := \
|
||||
common/subdaemon.o \
|
||||
common/type_to_string.o \
|
||||
common/utils.o \
|
||||
common/version.o
|
||||
common/version.o \
|
||||
common/wire_error.o
|
||||
|
||||
closingd/gen_closing_wire.h: $(WIRE_GEN) closingd/closing_wire.csv
|
||||
$(WIRE_GEN) --header $@ closing_wire_type < closingd/closing_wire.csv > $@
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <common/crypto_sync.h>
|
||||
#include <common/peer_failed.h>
|
||||
#include <common/status.h>
|
||||
#include <common/wire_error.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
@ -31,9 +32,10 @@ void peer_failed(int peer_fd, struct crypto_state *cs,
|
||||
va_start(ap, fmt);
|
||||
errmsg = tal_vfmt(NULL, fmt, ap);
|
||||
va_end(ap);
|
||||
/* Make sure it's correct length for error. */
|
||||
tal_resize(&errmsg, strlen(errmsg)+1);
|
||||
msg = towire_error(errmsg, channel_id, (const u8 *)errmsg);
|
||||
|
||||
va_start(ap, fmt);
|
||||
msg = towire_errorfmtv(errmsg, channel_id, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* This is only best-effort; don't block. */
|
||||
io_fd_block(peer_fd, false);
|
||||
|
Loading…
Reference in New Issue
Block a user