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:
Rusty Russell
2018-01-10 15:16:54 +10:30
committed by Christian Decker
parent 7865b4a679
commit e34ec8da2d
2 changed files with 7 additions and 4 deletions

View File

@@ -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);