1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

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.
This commit is contained in:
Simon Tatham 2018-06-13 19:42:19 +01:00
parent 93afcf02af
commit 281d317ab9
3 changed files with 5 additions and 5 deletions

View File

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

View File

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

View File

@ -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) {
/*