Skip to content

Commit e34ec8d

Browse files
rustyrussellcdecker
authored andcommitted
peer_failed: use towire_errorfmtv() which doesn't add nul terminator.
This code was actually wrong. Signed-off-by: Rusty Russell <[email protected]>
1 parent 7865b4a commit e34ec8d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

closingd/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ CLOSINGD_COMMON_OBJS := \
5858
common/subdaemon.o \
5959
common/type_to_string.o \
6060
common/utils.o \
61-
common/version.o
61+
common/version.o \
62+
common/wire_error.o
6263

6364
closingd/gen_closing_wire.h: $(WIRE_GEN) closingd/closing_wire.csv
6465
$(WIRE_GEN) --header $@ closing_wire_type < closingd/closing_wire.csv > $@

common/peer_failed.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <common/crypto_sync.h>
44
#include <common/peer_failed.h>
55
#include <common/status.h>
6+
#include <common/wire_error.h>
67
#include <fcntl.h>
78
#include <stdarg.h>
89
#include <unistd.h>
@@ -31,9 +32,10 @@ void peer_failed(int peer_fd, struct crypto_state *cs,
3132
va_start(ap, fmt);
3233
errmsg = tal_vfmt(NULL, fmt, ap);
3334
va_end(ap);
34-
/* Make sure it's correct length for error. */
35-
tal_resize(&errmsg, strlen(errmsg)+1);
36-
msg = towire_error(errmsg, channel_id, (const u8 *)errmsg);
35+
36+
va_start(ap, fmt);
37+
msg = towire_errorfmtv(errmsg, channel_id, fmt, ap);
38+
va_end(ap);
3739

3840
/* This is only best-effort; don't block. */
3941
io_fd_block(peer_fd, false);

0 commit comments

Comments
 (0)