1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Stop using unqualified {GET,PUT}_32BIT.

Those were a reasonable abbreviation when the code almost never had to
deal with little-endian numbers, but they've crept into enough places
now (e.g. the ECC formatting) that I think I'd now prefer that every
use of the integer read/write macros was clearly marked with its
endianness.

So all uses of GET_??BIT and PUT_??BIT are now qualified. The special
versions in x11fwd.c, which used variable endianness because so does
the X11 protocol, are suffixed _X11 to make that clear, and where that
pushed line lengths over 80 characters I've taken the opportunity to
name a local variable to remind me of what that extra parameter
actually does.
This commit is contained in:
Simon Tatham
2019-02-04 07:39:03 +00:00
parent 5538091f0d
commit acc21c4c0f
17 changed files with 56 additions and 58 deletions

View File

@ -73,7 +73,7 @@ static bool agent_try_read(agent_pending_query *conn)
}
conn->retlen += ret;
if (conn->retsize == 4 && conn->retlen == 4) {
conn->retsize = toint(GET_32BIT(conn->retbuf) + 4);
conn->retsize = toint(GET_32BIT_MSB_FIRST(conn->retbuf) + 4);
if (conn->retsize <= 0) {
conn->retbuf = NULL;
conn->retlen = 0;

View File

@ -93,8 +93,8 @@ static void uss_return_handle_raw(
UnixSftpServer *uss, SftpReplyBuilder *reply, int index, unsigned seq)
{
unsigned char handlebuf[8];
PUT_32BIT(handlebuf, index);
PUT_32BIT(handlebuf + 4, seq);
PUT_32BIT_MSB_FIRST(handlebuf, index);
PUT_32BIT_MSB_FIRST(handlebuf + 4, seq);
des_encrypt_xdmauth(uss->handlekey, handlebuf, 8);
fxp_reply_handle(reply, make_ptrlen(handlebuf, 8));
}
@ -108,8 +108,8 @@ static bool uss_decode_handle(
return false;
memcpy(handlebuf, handle.ptr, 8);
des_decrypt_xdmauth(uss->handlekey, handlebuf, 8);
*index = toint(GET_32BIT(handlebuf));
*seq = GET_32BIT(handlebuf + 4);
*index = toint(GET_32BIT_MSB_FIRST(handlebuf));
*seq = GET_32BIT_MSB_FIRST(handlebuf + 4);
return true;
}