aboutsummaryrefslogtreecommitdiff
path: root/src/agent.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/agent.c')
-rw-r--r--src/agent.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/src/agent.c b/src/agent.c
index 96e5a69c..d1ea5c08 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -56,33 +56,13 @@
#include "libssh/session.h"
#include "libssh/poll.h"
#include "libssh/pki.h"
+#include "libssh/bytearray.h"
/* macro to check for "agent failure" message */
#define agent_failed(x) \
(((x) == SSH_AGENT_FAILURE) || ((x) == SSH_COM_AGENT2_FAILURE) || \
((x) == SSH2_AGENT_FAILURE))
-static uint32_t agent_get_u32(const void *vp) {
- const uint8_t *p = (const uint8_t *)vp;
- uint32_t v;
-
- v = (uint32_t)p[0] << 24;
- v |= (uint32_t)p[1] << 16;
- v |= (uint32_t)p[2] << 8;
- v |= (uint32_t)p[3];
-
- return v;
-}
-
-static void agent_put_u32(void *vp, uint32_t v) {
- uint8_t *p = (uint8_t *)vp;
-
- p[0] = (uint8_t)(v >> 24) & 0xff;
- p[1] = (uint8_t)(v >> 16) & 0xff;
- p[2] = (uint8_t)(v >> 8) & 0xff;
- p[3] = (uint8_t)v & 0xff;
-}
-
static size_t atomicio(struct ssh_agent_struct *agent, void *buf, size_t n, int do_read) {
char *b = buf;
size_t pos = 0;
@@ -275,7 +255,7 @@ static int agent_talk(struct ssh_session_struct *session,
len = ssh_buffer_get_len(request);
SSH_LOG(SSH_LOG_TRACE, "Request length: %u", len);
- agent_put_u32(payload, len);
+ PUSH_BE_U32(payload, 0, len);
/* send length and then the request packet */
if (atomicio(session->agent, payload, 4, 0) == 4) {
@@ -299,7 +279,7 @@ static int agent_talk(struct ssh_session_struct *session,
return -1;
}
- len = agent_get_u32(payload);
+ len = PULL_BE_U32(payload, 0);
if (len > 256 * 1024) {
ssh_set_error(session, SSH_FATAL,
"Authentication response too long: %u", len);