From 281d317ab9f37210b9340cce6d7725cf7c9acf27 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 13 Jun 2018 19:42:19 +0100 Subject: [PATCH] Make put_padding() have a consistent argument order. Thanks to Alex Landau for pointing out that commit 8b98fea4a introduced two uses of it with the arguments one way round and one with them the other way round. (Plus a fourth use where it doesn't matter, because the padding at the end of the encrypted blob of an OpenSSH PEM private key consists of n bytes with value n. :-) On the basis of majority vote, I've switched the order in the function definition to match the two of the three call sites that expressed the same opinion, and fixed the third. --- marshal.c | 2 +- marshal.h | 6 +++--- ssh2bpp.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/marshal.c b/marshal.c index a8371b66..f0612a85 100644 --- a/marshal.c +++ b/marshal.c @@ -11,7 +11,7 @@ void BinarySink_put_data(BinarySink *bs, const void *data, size_t len) bs->write(bs, data, len); } -void BinarySink_put_padding(BinarySink *bs, unsigned char padbyte, size_t len) +void BinarySink_put_padding(BinarySink *bs, size_t len, unsigned char padbyte) { char buf[16]; memset(buf, padbyte, sizeof(buf)); diff --git a/marshal.h b/marshal.h index 0debe82f..2aa0301a 100644 --- a/marshal.h +++ b/marshal.h @@ -111,8 +111,8 @@ struct BinarySink { BinarySink_put_mp_ssh2(BinarySink_UPCAST(bs), val) /* Padding with a specified byte. */ -#define put_padding(bs, padbyte, len) \ - BinarySink_put_padding(BinarySink_UPCAST(bs), padbyte, len) +#define put_padding(bs, len, padbyte) \ + BinarySink_put_padding(BinarySink_UPCAST(bs), len, padbyte) /* Fallback: just emit raw data bytes, using a syntax that matches the * rest of these macros. */ @@ -130,7 +130,7 @@ struct BinarySink { * declaration(s) of their other parameter type(s) are in scope. */ void BinarySink_put_data(BinarySink *, const void *data, size_t len); -void BinarySink_put_padding(BinarySink *, unsigned char padbyte, size_t len); +void BinarySink_put_padding(BinarySink *, size_t len, unsigned char padbyte); void BinarySink_put_byte(BinarySink *, unsigned char); void BinarySink_put_bool(BinarySink *, int); void BinarySink_put_uint16(BinarySink *, unsigned long); diff --git a/ssh2bpp.c b/ssh2bpp.c index da0ac900..0ea1f793 100644 --- a/ssh2bpp.c +++ b/ssh2bpp.c @@ -582,7 +582,7 @@ static void ssh2_bpp_format_packet(BinaryPacketProtocol *bpp, PktOut *pkt) s->out.sequence); } - put_padding(pkt, 0, maclen); + put_padding(pkt, maclen, 0); if (s->out.mac && s->out.etm_mode) { /*