mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
wire: restore BE endian to wire headers for internal messages.
We don't anticipate daemons across machines, but you never know. Suggested-by: Christian Decker Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
3d316518fd
commit
29b83aed2a
@@ -7,12 +7,12 @@
|
||||
|
||||
bool wire_sync_write(int fd, const void *msg TAKES)
|
||||
{
|
||||
wire_len_t len = tal_len(msg);
|
||||
wire_len_t hdr = cpu_to_wirelen(tal_len(msg));
|
||||
bool ret;
|
||||
|
||||
assert(tal_len(msg) < WIRE_LEN_LIMIT);
|
||||
ret = write_all(fd, &len, sizeof(len))
|
||||
&& write_all(fd, msg, len);
|
||||
ret = write_all(fd, &hdr, sizeof(hdr))
|
||||
&& write_all(fd, msg, tal_count(msg));
|
||||
|
||||
if (taken(msg))
|
||||
tal_free(msg);
|
||||
@@ -26,12 +26,12 @@ u8 *wire_sync_read(const tal_t *ctx, int fd)
|
||||
|
||||
if (!read_all(fd, &len, sizeof(len)))
|
||||
return NULL;
|
||||
if (len >= WIRE_LEN_LIMIT) {
|
||||
if (wirelen_to_cpu(len) >= WIRE_LEN_LIMIT) {
|
||||
errno = E2BIG;
|
||||
return NULL;
|
||||
}
|
||||
msg = tal_arr(ctx, u8, len);
|
||||
if (!read_all(fd, msg, len))
|
||||
msg = tal_arr(ctx, u8, wirelen_to_cpu(len));
|
||||
if (!read_all(fd, msg, wirelen_to_cpu(len)))
|
||||
return tal_free(msg);
|
||||
return msg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user