diff options
-rw-r--r-- | include/libssh/priv.h | 98 | ||||
-rw-r--r-- | libssh/agent.c | 40 | ||||
-rw-r--r-- | libssh/auth.c | 8 | ||||
-rw-r--r-- | libssh/buffer.c | 54 | ||||
-rw-r--r-- | libssh/channels.c | 42 | ||||
-rw-r--r-- | libssh/channels1.c | 2 | ||||
-rw-r--r-- | libssh/crc32.c | 6 | ||||
-rw-r--r-- | libssh/crypt.c | 16 | ||||
-rw-r--r-- | libssh/dh.c | 2 | ||||
-rw-r--r-- | libssh/kex.c | 16 | ||||
-rw-r--r-- | libssh/messages.c | 16 | ||||
-rw-r--r-- | libssh/misc.c | 8 | ||||
-rw-r--r-- | libssh/packet.c | 48 | ||||
-rw-r--r-- | libssh/sftp.c | 92 | ||||
-rw-r--r-- | libssh/sftpserver.c | 12 | ||||
-rw-r--r-- | libssh/socket.c | 16 |
16 files changed, 235 insertions, 241 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 87595fc8..925d55d2 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -49,12 +49,6 @@ #define TYPE_RSA 2 #define TYPE_RSA1 3 -/* integer values */ -typedef uint32_t u32; -typedef uint16_t u16; -typedef uint64_t u64; -typedef uint8_t u8; - /* profiling constants. Don't touch them unless you know what you do */ #ifdef HAVE_LIBCRYPTO #define OPENSSL_BIGNUMS @@ -179,7 +173,7 @@ void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len); /* strings and buffers */ /* must be 32 bits number + immediatly our data */ struct ssh_string_struct { - u32 size; + uint32_t size; unsigned char string[MAX_PACKET_LEN]; } #if !defined(__SUNPRO_C) @@ -191,16 +185,16 @@ __attribute__ ((packed)) */ struct ssh_buffer_struct { char *data; - u32 used; - u32 allocated; - u32 pos; + uint32_t used; + uint32_t allocated; + uint32_t pos; }; /* i should remove it one day */ typedef struct packet_struct { int valid; - u32 len; - u8 type; + uint32_t len; + uint8_t type; } PACKET; typedef struct kex_struct { @@ -305,15 +299,15 @@ struct ssh_channel_struct { struct ssh_channel_struct *prev; struct ssh_channel_struct *next; SSH_SESSION *session; /* SSH_SESSION pointer */ - u32 local_channel; - u32 local_window; + uint32_t local_channel; + uint32_t local_window; int local_eof; - u32 local_maxpacket; + uint32_t local_maxpacket; - u32 remote_channel; - u32 remote_window; + uint32_t remote_channel; + uint32_t remote_window; int remote_eof; /* end of file received */ - u32 remote_maxpacket; + uint32_t remote_maxpacket; int open; /* shows if the channel is still opened */ int delayed_close; ssh_buffer stdout_buffer; @@ -346,8 +340,8 @@ struct ssh_session_struct { int protoversion; int server; int client; - u32 send_seq; - u32 recv_seq; + uint32_t send_seq; + uint32_t recv_seq; /* status flags */ int closed; int closed_by_except; @@ -406,7 +400,7 @@ struct ssh_session_struct { }; struct ssh_kbdint_struct { - u32 nprompts; + uint32_t nprompts; char *name; char *instruction; char **prompts; @@ -432,13 +426,13 @@ struct ssh_auth_request { struct ssh_channel_request_open { int type; - u32 sender; - u32 window; - u32 packet_size; + uint32_t sender; + uint32_t window; + uint32_t packet_size; char *originator; - u16 orignator_port; + uint16_t orignator_port; char *destination; - u16 destination_port; + uint16_t destination_port; }; struct ssh_service_request { @@ -448,13 +442,13 @@ struct ssh_service_request { struct ssh_channel_request { int type; ssh_channel channel; - u8 want_reply; + uint8_t want_reply; /* pty-req type specifics */ char *TERM; - u32 width; - u32 height; - u32 pxwidth; - u32 pxheight; + uint32_t width; + uint32_t height; + uint32_t pxwidth; + uint32_t pxheight; ssh_string modes; /* env type request */ @@ -568,9 +562,9 @@ int ssh_socket_write(struct socket *s,const void *buffer, int len); int ssh_socket_is_open(struct socket *s); int ssh_socket_fd_isset(struct socket *s, fd_set *set); void ssh_socket_fd_set(struct socket *s, fd_set *set, int *fd_max); -int ssh_socket_completeread(struct socket *s, void *buffer, u32 len); -int ssh_socket_completewrite(struct socket *s, const void *buffer, u32 len); -int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session, u32 len); +int ssh_socket_completeread(struct socket *s, void *buffer, uint32_t len); +int ssh_socket_completewrite(struct socket *s, const void *buffer, uint32_t len); +int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session, uint32_t len); int ssh_socket_nonblocking_flush(struct socket *s); int ssh_socket_blocking_flush(struct socket *s); int ssh_socket_poll(struct socket *s, int *writeable, int *except); @@ -620,7 +614,7 @@ bignum make_string_bn(ssh_string string); ssh_string make_bignum_string(bignum num); /* in crypt.c */ -u32 packet_decrypt_len(SSH_SESSION *session,char *crypted); +uint32_t packet_decrypt_len(SSH_SESSION *session,char *crypted); int packet_decrypt(SSH_SESSION *session, void *packet,unsigned int len); unsigned char *packet_encrypt(SSH_SESSION *session,void *packet,unsigned int len); /* it returns the hmac buffer if exists*/ @@ -687,8 +681,8 @@ void channel_handle(SSH_SESSION *session, int type); ssh_channel channel_new(SSH_SESSION *session); int channel_default_bufferize(ssh_channel channel, void *data, int len, int is_stderr); -u32 ssh_channel_new_id(SSH_SESSION *session); -ssh_channel ssh_channel_from_local(SSH_SESSION *session, u32 id); +uint32_t ssh_channel_new_id(SSH_SESSION *session); +ssh_channel ssh_channel_from_local(SSH_SESSION *session, uint32_t id); /* options.c */ @@ -699,32 +693,32 @@ int ssh_options_default_known_hosts_file(SSH_OPTIONS *opt); /* buffer.c */ int buffer_add_ssh_string(ssh_buffer buffer, ssh_string string); -int buffer_add_u8(ssh_buffer buffer, u8 data); -int buffer_add_u32(ssh_buffer buffer, u32 data); -int buffer_add_u64(ssh_buffer buffer, u64 data); -int buffer_add_data(ssh_buffer buffer, const void *data, u32 len); -int buffer_prepend_data(ssh_buffer buffer, const void *data, u32 len); +int buffer_add_u8(ssh_buffer buffer, uint8_t data); +int buffer_add_u32(ssh_buffer buffer, uint32_t data); +int buffer_add_u64(ssh_buffer buffer, uint64_t data); +int buffer_add_data(ssh_buffer buffer, const void *data, uint32_t len); +int buffer_prepend_data(ssh_buffer buffer, const void *data, uint32_t len); int buffer_add_buffer(ssh_buffer buffer, ssh_buffer source); int buffer_reinit(ssh_buffer buffer); /* buffer_get_rest returns a pointer to the current position into the buffer */ void *buffer_get_rest(ssh_buffer buffer); /* buffer_get_rest_len returns the number of bytes which can be read */ -u32 buffer_get_rest_len(ssh_buffer buffer); +uint32_t buffer_get_rest_len(ssh_buffer buffer); /* buffer_read_*() returns the number of bytes read, except for ssh strings */ -int buffer_get_u8(ssh_buffer buffer, u8 *data); -int buffer_get_u32(ssh_buffer buffer, u32 *data); -int buffer_get_u64(ssh_buffer buffer, u64 *data); +int buffer_get_u8(ssh_buffer buffer, uint8_t *data); +int buffer_get_u32(ssh_buffer buffer, uint32_t *data); +int buffer_get_u64(ssh_buffer buffer, uint64_t *data); -u32 buffer_get_data(ssh_buffer buffer, void *data, u32 requestedlen); +uint32_t buffer_get_data(ssh_buffer buffer, void *data, uint32_t requestedlen); /* buffer_get_ssh_string() is an exception. if the String read is too large or invalid, it will answer NULL. */ ssh_string buffer_get_ssh_string(ssh_buffer buffer); /* gets a string out of a SSH-1 mpint */ ssh_string buffer_get_mpint(ssh_buffer buffer); /* buffer_pass_bytes acts as if len bytes have been read (used for padding) */ -u32 buffer_pass_bytes_end(ssh_buffer buffer, u32 len); -u32 buffer_pass_bytes(ssh_buffer buffer, u32 len); +uint32_t buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len); +uint32_t buffer_pass_bytes(ssh_buffer buffer, uint32_t len); /* in base64.c */ ssh_buffer base64_to_bin(const char *source); @@ -741,7 +735,7 @@ CRYPTO *crypto_new(void); void crypto_free(CRYPTO *crypto); /* crc32.c */ -u32 ssh_crc32(const char *buf, u32 len); +uint32_t ssh_crc32(const char *buf, uint32_t len); /* auth1.c */ int ssh_userauth1_none(SSH_SESSION *session, const char *username); @@ -755,7 +749,7 @@ char *ssh_get_user_home_dir(void); int ssh_file_readaccess_ok(const char *file); /* macro for byte ordering */ -u64 ntohll(u64); +uint64_t ntohll(uint64_t); #define htonll(x) ntohll(x) /* list processing */ @@ -812,7 +806,7 @@ int match_hostname(const char *host, const char *pattern, unsigned int len); /* messages.c */ -void message_handle(SSH_SESSION *session, u32 type); +void message_handle(SSH_SESSION *session, uint32_t type); int ssh_execute_message_callbacks(SSH_SESSION *session); /* log.c */ diff --git a/libssh/agent.c b/libssh/agent.c index 1235dcac..e6fe85f8 100644 --- a/libssh/agent.c +++ b/libssh/agent.c @@ -56,25 +56,25 @@ (((x) == SSH_AGENT_FAILURE) || ((x) == SSH_COM_AGENT2_FAILURE) || \ ((x) == SSH2_AGENT_FAILURE)) -static u32 agent_get_u32(const void *vp) { - const u8 *p = (const u8 *)vp; - u32 v; +static uint32_t agent_get_u32(const void *vp) { + const uint8_t *p = (const uint8_t *)vp; + uint32_t v; - v = (u32)p[0] << 24; - v |= (u32)p[1] << 16; - v |= (u32)p[2] << 8; - v |= (u32)p[3]; + 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, u32 v) { - u8 *p = (u8 *)vp; +static void agent_put_u32(void *vp, uint32_t v) { + uint8_t *p = (uint8_t *)vp; - p[0] = (u8)(v >> 24) & 0xff; - p[1] = (u8)(v >> 16) & 0xff; - p[2] = (u8)(v >> 8) & 0xff; - p[3] = (u8)v & 0xff; + 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 socket *s, void *buf, size_t n, int do_read) { @@ -201,8 +201,8 @@ static int agent_decode_reply(struct ssh_session_struct *session, int type) { static int agent_talk(struct ssh_session_struct *session, struct ssh_buffer_struct *request, struct ssh_buffer_struct *reply) { - u32 len = 0; - u8 payload[1024] = {0}; + uint32_t len = 0; + uint8_t payload[1024] = {0}; len = buffer_get_len(request); ssh_log(session, SSH_LOG_PACKET, "agent_talk - len of request: %u", len); @@ -267,7 +267,7 @@ int agent_get_ident_count(struct ssh_session_struct *session) { ssh_buffer reply = NULL; unsigned int type = 0; unsigned int c1 = 0, c2 = 0; - u8 buf[4] = {0}; + uint8_t buf[4] = {0}; switch (session->version) { case 1: @@ -302,7 +302,7 @@ int agent_get_ident_count(struct ssh_session_struct *session) { buffer_free(request); /* get message type and verify the answer */ - buffer_get_u8(reply, (u8 *) &type); + buffer_get_u8(reply, (uint8_t *) &type); ssh_log(session, SSH_LOG_PACKET, "agent_ident_count - answer type: %d, expected answer: %d", type, c2); @@ -314,7 +314,7 @@ int agent_get_ident_count(struct ssh_session_struct *session) { return -1; } - buffer_get_u32(reply, (u32 *) buf); + buffer_get_u32(reply, (uint32_t *) buf); session->agent->count = agent_get_u32(buf); ssh_log(session, SSH_LOG_PACKET, "agent_ident_count - count: %d", session->agent->count); @@ -403,7 +403,7 @@ ssh_string agent_sign_data(struct ssh_session_struct *session, struct ssh_buffer_struct *reply = NULL; int type = SSH2_AGENT_FAILURE; int flags = 0; - u32 dlen = 0; + uint32_t dlen = 0; /* create blob from the pubkey */ blob = publickey_to_string(pubkey); @@ -451,7 +451,7 @@ ssh_string agent_sign_data(struct ssh_session_struct *session, buffer_free(request); /* check if reply is valid */ - if (buffer_get_u8(reply, (u8 *) &type) < 0) { + if (buffer_get_u8(reply, (uint8_t *) &type) < 0) { goto error; } if (agent_failed(type)) { diff --git a/libssh/auth.c b/libssh/auth.c index 566afcd4..6c38095a 100644 --- a/libssh/auth.c +++ b/libssh/auth.c @@ -61,7 +61,7 @@ static int wait_auth_status(SSH_SESSION *session, int kbdint) { ssh_string auth; int rc = SSH_AUTH_ERROR; int cont = 1; - u8 partial = 0; + uint8_t partial = 0; enter_function(); @@ -1137,8 +1137,8 @@ static int kbdauth_info_get(SSH_SESSION *session) { ssh_string name; /* name of the "asking" window showed to client */ ssh_string instruction; ssh_string tmp; - u32 nprompts; - u32 i; + uint32_t nprompts; + uint32_t i; enter_function(); @@ -1253,7 +1253,7 @@ static int kbdauth_info_get(SSH_SESSION *session) { static int kbdauth_send(SSH_SESSION *session) { ssh_string answer = NULL; int rc = SSH_AUTH_ERROR; - u32 i; + uint32_t i; enter_function(); diff --git a/libssh/buffer.c b/libssh/buffer.c index b3d5186a..d3d249e4 100644 --- a/libssh/buffer.c +++ b/libssh/buffer.c @@ -143,7 +143,7 @@ int buffer_reinit(struct ssh_buffer_struct *buffer) { * \param data data pointer * \param len length of data */ -int buffer_add_data(struct ssh_buffer_struct *buffer, const void *data, u32 len) { +int buffer_add_data(struct ssh_buffer_struct *buffer, const void *data, uint32_t len) { buffer_verify(buffer); if (buffer->allocated < (buffer->used + len)) { if (realloc_buffer(buffer, buffer->used + len) < 0) { @@ -165,10 +165,10 @@ int buffer_add_data(struct ssh_buffer_struct *buffer, const void *data, u32 len) */ int buffer_add_ssh_string(struct ssh_buffer_struct *buffer, struct ssh_string_struct *string) { - u32 len = 0; + uint32_t len = 0; len = ntohl(string->size); - if (buffer_add_data(buffer, string, len + sizeof(u32)) < 0) { + if (buffer_add_data(buffer, string, len + sizeof(uint32_t)) < 0) { return -1; } @@ -180,7 +180,7 @@ int buffer_add_ssh_string(struct ssh_buffer_struct *buffer, * \param data 32 bits integer * \return 0 on success, -1 on error. */ -int buffer_add_u32(struct ssh_buffer_struct *buffer,u32 data){ +int buffer_add_u32(struct ssh_buffer_struct *buffer,uint32_t data){ if (buffer_add_data(buffer, &data, sizeof(data)) < 0) { return -1; } @@ -194,7 +194,7 @@ int buffer_add_u32(struct ssh_buffer_struct *buffer,u32 data){ * \param data 64 bits integer * \return 0 on success, -1 on error. */ -int buffer_add_u64(struct ssh_buffer_struct *buffer, u64 data){ +int buffer_add_u64(struct ssh_buffer_struct *buffer, uint64_t data){ if (buffer_add_data(buffer, &data, sizeof(data)) < 0) { return -1; } @@ -207,8 +207,8 @@ int buffer_add_u64(struct ssh_buffer_struct *buffer, u64 data){ * \param data 8 bits integer * \return 0 on success, -1 on error. */ -int buffer_add_u8(struct ssh_buffer_struct *buffer,u8 data){ - if (buffer_add_data(buffer, &data, sizeof(u8)) < 0) { +int buffer_add_u8(struct ssh_buffer_struct *buffer,uint8_t data){ + if (buffer_add_data(buffer, &data, sizeof(uint8_t)) < 0) { return -1; } @@ -223,7 +223,7 @@ int buffer_add_u8(struct ssh_buffer_struct *buffer,u8 data){ * \return 0 on success, -1 on error. */ int buffer_prepend_data(struct ssh_buffer_struct *buffer, const void *data, - u32 len) { + uint32_t len) { buffer_verify(buffer); if (buffer->allocated < (buffer->used + len)) { if (realloc_buffer(buffer, buffer->used + len) < 0) { @@ -279,7 +279,7 @@ void *buffer_get_rest(struct ssh_buffer_struct *buffer){ * \return length of the buffer * \see buffer_get() */ -u32 buffer_get_len(struct ssh_buffer_struct *buffer){ +uint32_t buffer_get_len(struct ssh_buffer_struct *buffer){ return buffer->used; } @@ -289,7 +289,7 @@ u32 buffer_get_len(struct ssh_buffer_struct *buffer){ * \return length of the buffer * \see buffer_get_rest() */ -u32 buffer_get_rest_len(struct ssh_buffer_struct *buffer){ +uint32_t buffer_get_rest_len(struct ssh_buffer_struct *buffer){ buffer_verify(buffer); return buffer->used - buffer->pos; } @@ -301,7 +301,7 @@ u32 buffer_get_rest_len(struct ssh_buffer_struct *buffer){ * \param len number of bytes to eat * \return new size of the buffer */ -u32 buffer_pass_bytes(struct ssh_buffer_struct *buffer, u32 len){ +uint32_t buffer_pass_bytes(struct ssh_buffer_struct *buffer, uint32_t len){ buffer_verify(buffer); if(buffer->used < buffer->pos+len) return 0; @@ -321,7 +321,7 @@ u32 buffer_pass_bytes(struct ssh_buffer_struct *buffer, u32 len){ * \param len number of bytes to remove from tail * \return new size of the buffer */ -u32 buffer_pass_bytes_end(struct ssh_buffer_struct *buffer, u32 len){ +uint32_t buffer_pass_bytes_end(struct ssh_buffer_struct *buffer, uint32_t len){ buffer_verify(buffer); if(buffer->used < buffer->pos + len) return 0; @@ -338,7 +338,7 @@ u32 buffer_pass_bytes_end(struct ssh_buffer_struct *buffer, u32 len){ * \returns 0 if there is not enough data in buffer * \returns len otherwise. */ -u32 buffer_get_data(struct ssh_buffer_struct *buffer, void *data, u32 len){ +uint32_t buffer_get_data(struct ssh_buffer_struct *buffer, void *data, uint32_t len){ if(buffer->pos+len>buffer->used) return 0; /*no enough data in buffer */ memcpy(data,buffer->data+buffer->pos,len); @@ -348,33 +348,33 @@ u32 buffer_get_data(struct ssh_buffer_struct *buffer, void *data, u32 len){ /** \internal * \brief gets a 8 bits unsigned int out of the buffer. Adjusts the read pointer. * \param buffer Buffer to read - * \param data pointer to a u8 where to store the data + * \param data pointer to a uint8_t where to store the data * \returns 0 if there is not enough data in buffer * \returns 1 otherwise. */ -int buffer_get_u8(struct ssh_buffer_struct *buffer, u8 *data){ - return buffer_get_data(buffer,data,sizeof(u8)); +int buffer_get_u8(struct ssh_buffer_struct *buffer, uint8_t *data){ + return buffer_get_data(buffer,data,sizeof(uint8_t)); } /** \internal * \brief gets a 32 bits unsigned int out of the buffer. Adjusts the read pointer. * \param buffer Buffer to read - * \param data pointer to a u32 where to store the data + * \param data pointer to a uint32_t where to store the data * \returns 0 if there is not enough data in buffer * \returns 4 otherwise. */ -int buffer_get_u32(struct ssh_buffer_struct *buffer, u32 *data){ - return buffer_get_data(buffer,data,sizeof(u32)); +int buffer_get_u32(struct ssh_buffer_struct *buffer, uint32_t *data){ + return buffer_get_data(buffer,data,sizeof(uint32_t)); } /** \internal * \brief gets a 64 bits unsigned int out of the buffer. Adjusts the read pointer. * \param buffer Buffer to read - * \param data pointer to a u64 where to store the data + * \param data pointer to a uint64_t where to store the data * \returns 0 if there is not enough data in buffer * \returns 8 otherwise. */ -int buffer_get_u64(struct ssh_buffer_struct *buffer, u64 *data){ - return buffer_get_data(buffer,data,sizeof(u64)); +int buffer_get_u64(struct ssh_buffer_struct *buffer, uint64_t *data){ + return buffer_get_data(buffer,data,sizeof(uint64_t)); } /** \internal * \brief gets a SSH String out of the buffer. Adjusts the read pointer. @@ -383,8 +383,8 @@ int buffer_get_u64(struct ssh_buffer_struct *buffer, u64 *data){ * \returns NULL otherwise. */ struct ssh_string_struct *buffer_get_ssh_string(struct ssh_buffer_struct *buffer) { - u32 stringlen; - u32 hostlen; + uint32_t stringlen; + uint32_t hostlen; struct ssh_string_struct *str = NULL; if (buffer_get_u32(buffer, &stringlen) == 0) { @@ -416,11 +416,11 @@ struct ssh_string_struct *buffer_get_ssh_string(struct ssh_buffer_struct *buffer */ struct ssh_string_struct *buffer_get_mpint(struct ssh_buffer_struct *buffer) { - u16 bits; - u32 len; + uint16_t bits; + uint32_t len; struct ssh_string_struct *str = NULL; - if (buffer_get_data(buffer, &bits, sizeof(u16)) != sizeof(u16)) { + if (buffer_get_data(buffer, &bits, sizeof(uint16_t)) != sizeof(uint16_t)) { return NULL; } bits = ntohs(bits); diff --git a/libssh/channels.c b/libssh/channels.c index cfe1808a..88069bb7 100644 --- a/libssh/channels.c +++ b/libssh/channels.c @@ -102,7 +102,7 @@ ssh_channel channel_new(SSH_SESSION *session) { * * @return The new channel identifier. */ -u32 ssh_channel_new_id(SSH_SESSION *session) { +uint32_t ssh_channel_new_id(SSH_SESSION *session) { return ++(session->maxchannel); } @@ -110,7 +110,7 @@ static int channel_open(ssh_channel channel, const char *type_c, int window, int maxpacket, ssh_buffer payload) { SSH_SESSION *session = channel->session; ssh_string type = NULL; - u32 tmp = 0; + uint32_t tmp = 0; enter_function(); @@ -198,7 +198,7 @@ static int channel_open(ssh_channel channel, const char *type_c, int window, { ssh_string error_s; char *error; - u32 code; + uint32_t code; buffer_get_u32(session->in_buffer, &tmp); buffer_get_u32(session->in_buffer, &code); @@ -233,7 +233,7 @@ static int channel_open(ssh_channel channel, const char *type_c, int window, } /* get ssh channel from local session? */ -ssh_channel ssh_channel_from_local(SSH_SESSION *session, u32 id) { +ssh_channel ssh_channel_from_local(SSH_SESSION *session, uint32_t id) { ssh_channel initchan = session->channels; ssh_channel channel; @@ -253,7 +253,7 @@ ssh_channel ssh_channel_from_local(SSH_SESSION *session, u32 id) { } static int grow_window(SSH_SESSION *session, ssh_channel channel, int minimumsize) { - u32 new_window = minimumsize > WINDOWBASE ? minimumsize : WINDOWBASE; + uint32_t new_window = minimumsize > WINDOWBASE ? minimumsize : WINDOWBASE; enter_function(); @@ -288,9 +288,9 @@ error: static ssh_channel channel_from_msg(SSH_SESSION *session) { ssh_channel channel; - u32 chan; + uint32_t chan; - if (buffer_get_u32(session->in_buffer, &chan) != sizeof(u32)) { + if (buffer_get_u32(session->in_buffer, &chan) != sizeof(uint32_t)) { ssh_set_error(session, SSH_FATAL, "Getting channel from message: short read"); return NULL; @@ -308,7 +308,7 @@ static ssh_channel channel_from_msg(SSH_SESSION *session) { static void channel_rcv_change_window(SSH_SESSION *session) { ssh_channel channel; - u32 bytes; + uint32_t bytes; int rc; enter_function(); @@ -319,7 +319,7 @@ static void channel_rcv_change_window(SSH_SESSION *session) { } rc = buffer_get_u32(session->in_buffer, &bytes); - if (channel == NULL || rc != sizeof(u32)) { + if (channel == NULL || rc != sizeof(uint32_t)) { ssh_log(session, SSH_LOG_PACKET, "Error getting a window adjust message: invalid packet"); leave_function(); @@ -356,7 +356,7 @@ static void channel_rcv_data(SSH_SESSION *session,int is_stderr) { } if (is_stderr) { - u32 ignore; + uint32_t ignore; /* uint32 data type code. we can ignore it */ buffer_get_u32(session->in_buffer, &ignore); } @@ -471,7 +471,7 @@ static void channel_rcv_request(SSH_SESSION *session) { ssh_channel channel; ssh_string request_s; char *request; - u32 status; + uint32_t status; enter_function(); @@ -496,7 +496,7 @@ static void channel_rcv_request(SSH_SESSION *session) { return; } - buffer_get_u8(session->in_buffer, (u8 *) &status); + buffer_get_u8(session->in_buffer, (uint8_t *) &status); if (strcmp(request,"exit-status") == 0) { SAFE_FREE(request); @@ -512,7 +512,7 @@ static void channel_rcv_request(SSH_SESSION *session) { const char *core = "(core dumped)"; ssh_string signal_s; char *signal; - u8 i; + uint8_t i; SAFE_FREE(request); @@ -865,7 +865,7 @@ error: * * @see channel_read() */ -int channel_write(ssh_channel channel, const void *data, u32 len) { +int channel_write(ssh_channel channel, const void *data, uint32_t len) { SSH_SESSION *session = channel->session; int origlen = len; int effectivelen; @@ -1359,12 +1359,12 @@ error: * * @return The number of bytes read, 0 on end of file or SSH_ERROR on error. */ -int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, u32 count, +int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, uint32_t count, int is_stderr) { SSH_SESSION *session=channel->session; ssh_buffer stdbuf = channel->stdout_buffer; - u32 maxread = count; - u32 len; + uint32_t maxread = count; + uint32_t len; buffer_reinit(buffer); @@ -1468,10 +1468,10 @@ int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, u32 count, * @warning The read function using a buffer has been renamed to * channel_read_buffer(). */ -int channel_read(ssh_channel channel, void *dest, u32 count, int is_stderr) { +int channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr) { SSH_SESSION *session = channel->session; ssh_buffer stdbuf = channel->stdout_buffer; - u32 len; + uint32_t len; enter_function(); @@ -1566,10 +1566,10 @@ int channel_read(ssh_channel channel, void *dest, u32 count, int is_stderr) { * * @see channel_is_eof() */ -int channel_read_nonblocking(ssh_channel channel, void *dest, u32 count, +int channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count, int is_stderr) { SSH_SESSION *session = channel->session; - u32 to_read; + uint32_t to_read; int rc; enter_function(); diff --git a/libssh/channels1.c b/libssh/channels1.c index c3db8447..d7cd7cb2 100644 --- a/libssh/channels1.c +++ b/libssh/channels1.c @@ -230,7 +230,7 @@ static int channel_rcv_data1(SSH_SESSION *session, int is_stderr) { static int channel_rcv_close1(SSH_SESSION *session) { ssh_channel channel = session->channels; - u32 status; + uint32_t status; buffer_get_u32(session->in_buffer, &status); /* diff --git a/libssh/crc32.c b/libssh/crc32.c index 1df7dbff..94d3020c 100644 --- a/libssh/crc32.c +++ b/libssh/crc32.c @@ -23,7 +23,7 @@ #include "libssh/priv.h" -static u32 crc_table[] = { +static uint32_t crc_table[] = { 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, @@ -78,8 +78,8 @@ static u32 crc_table[] = { 0x2d02ef8dUL }; -u32 ssh_crc32(const char *buf, u32 len) { - u32 ret = 0; +uint32_t ssh_crc32(const char *buf, uint32_t len) { + uint32_t ret = 0; while(len > 0) { ret = crc_table[(ret ^ *buf) & 0xff] ^ (ret >> 8); --len; diff --git a/libssh/crypt.c b/libssh/crypt.c index 655bcfab..e7f26339 100644 --- a/libssh/crypt.c +++ b/libssh/crypt.c @@ -39,8 +39,8 @@ #include "libssh/priv.h" #include "libssh/crypto.h" -u32 packet_decrypt_len(SSH_SESSION *session, char *crypted){ - u32 decrypted; +uint32_t packet_decrypt_len(SSH_SESSION *session, char *crypted){ + uint32_t decrypted; if (session->current_crypto) { if (packet_decrypt(session, crypted, @@ -57,7 +57,7 @@ u32 packet_decrypt_len(SSH_SESSION *session, char *crypted){ return ntohl(decrypted); } -int packet_decrypt(SSH_SESSION *session, void *data,u32 len) { +int packet_decrypt(SSH_SESSION *session, void *data,uint32_t len) { struct crypto_struct *crypto = session->current_crypto->in_cipher; char *out = NULL; @@ -90,12 +90,12 @@ int packet_decrypt(SSH_SESSION *session, void *data,u32 len) { return 0; } -unsigned char *packet_encrypt(SSH_SESSION *session, void *data, u32 len) { +unsigned char *packet_encrypt(SSH_SESSION *session, void *data, uint32_t len) { struct crypto_struct *crypto = NULL; HMACCTX ctx = NULL; char *out = NULL; unsigned int finallen; - u32 seq; + uint32_t seq; if (!session->current_crypto) { return NULL; /* nothing to do here */ @@ -132,7 +132,7 @@ unsigned char *packet_encrypt(SSH_SESSION *session, void *data, u32 len) { SAFE_FREE(out); return NULL; } - hmac_update(ctx,(unsigned char *)&seq,sizeof(u32)); + hmac_update(ctx,(unsigned char *)&seq,sizeof(uint32_t)); hmac_update(ctx,data,len); hmac_final(ctx,session->current_crypto->hmacbuf,&finallen); #ifdef DEBUG_CRYPTO @@ -179,7 +179,7 @@ int packet_hmac_verify(SSH_SESSION *session, ssh_buffer buffer, unsigned char hmacbuf[EVP_MAX_MD_SIZE] = {0}; HMACCTX ctx; unsigned int len; - u32 seq; + uint32_t seq; ctx = hmac_init(session->current_crypto->decryptMAC, 20, HMAC_SHA1); if (ctx == NULL) { @@ -188,7 +188,7 @@ int packet_hmac_verify(SSH_SESSION *session, ssh_buffer buffer, seq = htonl(session->recv_seq); - hmac_update(ctx, (unsigned char *) &seq, sizeof(u32)); + hmac_update(ctx, (unsigned char *) &seq, sizeof(uint32_t)); hmac_update(ctx, buffer_get(buffer), buffer_get_len(buffer)); hmac_final(ctx, hmacbuf, &len); diff --git a/libssh/dh.c b/libssh/dh.c index 26bcbc7a..b3512a90 100644 --- a/libssh/dh.c +++ b/libssh/dh.c @@ -480,7 +480,7 @@ int make_sessionid(SSH_SESSION *session) { ssh_buffer server_hash = NULL; ssh_buffer client_hash = NULL; ssh_buffer buf = NULL; - u32 len; + uint32_t len; int rc = SSH_ERROR; enter_function(); diff --git a/libssh/kex.c b/libssh/kex.c index c4ef6801..5927ba99 100644 --- a/libssh/kex.c +++ b/libssh/kex.c @@ -616,12 +616,12 @@ int ssh_get_kex1(SSH_SESSION *session) { ssh_string enc_session = NULL; ssh_public_key srv = NULL; ssh_public_key host = NULL; - u32 server_bits; - u32 host_bits; - u32 protocol_flags; - u32 supported_ciphers_mask; - u32 supported_authentications_mask; - u16 bits; + uint32_t server_bits; + uint32_t host_bits; + uint32_t protocol_flags; + uint32_t supported_ciphers_mask; + uint32_t supported_authentications_mask; + uint16_t bits; int rc = -1; int ko; @@ -661,7 +661,7 @@ int ssh_get_kex1(SSH_SESSION *session) { buffer_get_u32(session->in_buffer, &supported_ciphers_mask); ko = buffer_get_u32(session->in_buffer, &supported_authentications_mask); - if ((ko != sizeof(u32)) || !host_mod || !host_exp + if ((ko != sizeof(uint32_t)) || !host_mod || !host_exp || !server_mod || !server_exp) { ssh_log(session, SSH_LOG_RARE, "Invalid SSH_SMSG_PUBLIC_KEY packet"); ssh_set_error(session, SSH_FATAL, "Invalid SSH_SMSG_PUBLIC_KEY packet"); @@ -738,7 +738,7 @@ int ssh_get_kex1(SSH_SESSION *session) { bits, string_len(enc_session)); bits = htons(bits); /* the encrypted mpint */ - if (buffer_add_data(session->out_buffer, &bits, sizeof(u16)) < 0) { + if (buffer_add_data(session->out_buffer, &bits, sizeof(uint16_t)) < 0) { goto error; } if (buffer_add_data(session->out_buffer, enc_session->string, diff --git a/libssh/messages.c b/libssh/messages.c index 3f2f1540..c28a3ce6 100644 --- a/libssh/messages.c +++ b/libssh/messages.c @@ -193,7 +193,7 @@ static SSH_MESSAGE *handle_userauth_request(SSH_SESSION *session){ if (strcmp(method_c, "password") == 0) { ssh_string pass = NULL; - u8 tmp; + uint8_t tmp; msg->auth_request.method = SSH_AUTH_PASSWORD; SAFE_FREE(method_c); @@ -337,7 +337,7 @@ static SSH_MESSAGE *handle_channel_request_open(SSH_SESSION *session) { SSH_MESSAGE *msg = NULL; ssh_string type = NULL; char *type_c = NULL; - u32 sender, window, packet; + uint32_t sender, window, packet; enter_function(); @@ -481,8 +481,8 @@ static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session) { SSH_MESSAGE *msg = NULL; ssh_string type = NULL; char *type_c = NULL; - u32 channel; - u8 want_reply; + uint32_t channel; + uint8_t want_reply; enter_function(); @@ -624,7 +624,7 @@ char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg){ } int ssh_message_channel_request_reply_success(SSH_MESSAGE *msg) { - u32 channel; + uint32_t channel; if (msg == NULL) { return SSH_ERROR; @@ -653,7 +653,7 @@ int ssh_message_channel_request_reply_success(SSH_MESSAGE *msg) { } static int ssh_message_channel_request_reply_default(SSH_MESSAGE *msg) { - u32 channel; + uint32_t channel; if (msg->channel_request.want_reply) { channel = msg->channel_request.channel->remote_channel; @@ -677,7 +677,7 @@ static int ssh_message_channel_request_reply_default(SSH_MESSAGE *msg) { return SSH_OK; } -SSH_MESSAGE *ssh_message_retrieve(SSH_SESSION *session, u32 packettype){ +SSH_MESSAGE *ssh_message_retrieve(SSH_SESSION *session, uint32_t packettype){ SSH_MESSAGE *msg=NULL; enter_function(); switch(packettype) { @@ -807,7 +807,7 @@ void ssh_message_free(SSH_MESSAGE *msg){ * \param type packet type * \returns nothing */ -void message_handle(SSH_SESSION *session, u32 type){ +void message_handle(SSH_SESSION *session, uint32_t type){ SSH_MESSAGE *msg=ssh_message_retrieve(session,type); if(msg){ if(!session->ssh_message_list){ diff --git a/libssh/misc.c b/libssh/misc.c index 2de8b56f..5ab0501d 100644 --- a/libssh/misc.c +++ b/libssh/misc.c @@ -104,16 +104,16 @@ int ssh_file_readaccess_ok(const char *file) { return 1; } -u64 ntohll(u64 a) { +uint64_t ntohll(uint64_t a) { #ifdef WORDS_BIGENDIAN return a; #else - u32 low = a & 0xffffffff; - u32 high = a >> 32 ; + uint32_t low = a & 0xffffffff; + uint32_t high = a >> 32 ; low = ntohl(low); high = ntohl(high); - return ((((u64) low) << 32) | ( high)); + return ((((uint64_t) low) << 32) | ( high)); #endif } diff --git a/libssh/packet.c b/libssh/packet.c index f3742e4e..f58a8c24 100644 --- a/libssh/packet.c +++ b/libssh/packet.c @@ -58,8 +58,8 @@ static int packet_read2(SSH_SESSION *session) { int to_be_read; int rc = SSH_ERROR; - u32 len; - u8 padding; + uint32_t len; + uint8_t padding; enter_function(); @@ -103,7 +103,7 @@ static int packet_read2(SSH_SESSION *session) { goto error; } - to_be_read = len - blocksize + sizeof(u32); + to_be_read = len - blocksize + sizeof(uint32_t); if (to_be_read < 0) { /* remote sshd sends invalid sizes? */ ssh_set_error(session, SSH_FATAL, @@ -116,7 +116,7 @@ static int packet_read2(SSH_SESSION *session) { session->packet_state = PACKET_STATE_SIZEREAD; case PACKET_STATE_SIZEREAD: len = session->in_packet.len; - to_be_read = len - blocksize + sizeof(u32) + current_macsize; + to_be_read = len - blocksize + sizeof(uint32_t) + current_macsize; /* if to_be_read is zero, the whole packet was blocksize bytes. */ if (to_be_read != 0) { rc = ssh_socket_wait_for_data(session->socket,session,to_be_read); @@ -161,7 +161,7 @@ static int packet_read2(SSH_SESSION *session) { } } - buffer_pass_bytes(session->in_buffer, sizeof(u32)); + buffer_pass_bytes(session->in_buffer, sizeof(uint32_t)); /* pass the size which has been processed before */ if (buffer_get_u8(session->in_buffer, &padding) == 0) { @@ -220,9 +220,9 @@ static int packet_read1(SSH_SESSION *session) { void *packet = NULL; int rc = SSH_ERROR; int to_be_read; - u32 padding; - u32 crc; - u32 len; + uint32_t padding; + uint32_t crc; + uint32_t len; enter_function(); @@ -436,12 +436,12 @@ static int packet_write(SSH_SESSION *session) { static int packet_send2(SSH_SESSION *session) { unsigned int blocksize = (session->current_crypto ? session->current_crypto->out_cipher->blocksize : 8); - u32 currentlen = buffer_get_len(session->out_buffer); + uint32_t currentlen = buffer_get_len(session->out_buffer); unsigned char *hmac = NULL; char padstring[32] = {0}; int rc = SSH_ERROR; - u32 finallen; - u8 padding; + uint32_t finallen; + uint8_t padding; enter_function(); @@ -473,10 +473,10 @@ static int packet_send2(SSH_SESSION *session) { "%d bytes after comp + %d padding bytes = %lu bytes packet", currentlen, padding, (long unsigned int) ntohl(finallen)); - if (buffer_prepend_data(session->out_buffer, &padding, sizeof(u8)) < 0) { + if (buffer_prepend_data(session->out_buffer, &padding, sizeof(uint8_t)) < 0) { goto error; } - if (buffer_prepend_data(session->out_buffer, &finallen, sizeof(u32)) < 0) { + if (buffer_prepend_data(session->out_buffer, &finallen, sizeof(uint32_t)) < 0) { goto error; } if (buffer_add_data(session->out_buffer, padstring, padding) < 0) { @@ -506,12 +506,12 @@ error: static int packet_send1(SSH_SESSION *session) { unsigned int blocksize = (session->current_crypto ? session->current_crypto->out_cipher->blocksize : 8); - u32 currentlen = buffer_get_len(session->out_buffer) + sizeof(u32); + uint32_t currentlen = buffer_get_len(session->out_buffer) + sizeof(u32); char padstring[32] = {0}; int rc = SSH_ERROR; - u32 finallen; - u32 crc; - u8 padding; + uint32_t finallen; + uint32_t crc; + uint8_t padding; enter_function(); ssh_log(session,SSH_LOG_PACKET,"Sending a %d bytes long packet",currentlen); @@ -541,12 +541,12 @@ static int packet_send1(SSH_SESSION *session) { if (buffer_prepend_data(session->out_buffer, &padstring, padding) < 0) { goto error; } - if (buffer_prepend_data(session->out_buffer, &finallen, sizeof(u32)) < 0) { + if (buffer_prepend_data(session->out_buffer, &finallen, sizeof(uint32_t)) < 0) { goto error; } - crc = ssh_crc32(buffer_get(session->out_buffer) + sizeof(u32), - buffer_get_len(session->out_buffer) - sizeof(u32)); + crc = ssh_crc32(buffer_get(session->out_buffer) + sizeof(uint32_t), + buffer_get_len(session->out_buffer) - sizeof(uint32_t)); if (buffer_add_u32(session->out_buffer, ntohl(crc)) < 0) { goto error; @@ -557,8 +557,8 @@ static int packet_send1(SSH_SESSION *session) { buffer_get_len(session->out_buffer)); #endif - packet_encrypt(session, buffer_get(session->out_buffer) + sizeof(u32), - buffer_get_len(session->out_buffer) - sizeof(u32)); + packet_encrypt(session, buffer_get(session->out_buffer) + sizeof(uint32_t), + buffer_get_len(session->out_buffer) - sizeof(uint32_t)); #ifdef DEBUG_CRYPTO ssh_print_hexa("encrypted packet",buffer_get(session->out_buffer), @@ -594,8 +594,8 @@ int packet_send(SSH_SESSION *session) { void packet_parse(SSH_SESSION *session) { ssh_string error_s = NULL; char *error = NULL; - u32 type = session->in_packet.type; - u32 tmp; + uint32_t type = session->in_packet.type; + uint32_t tmp; #ifdef HAVE_SSH1 if (session->version == 1) { diff --git a/libssh/sftp.c b/libssh/sftp.c index df8bc2c0..f64aa302 100644 --- a/libssh/sftp.c +++ b/libssh/sftp.c @@ -112,7 +112,7 @@ int sftp_server_init(SFTP_SESSION *sftp){ ssh_session session = sftp->session; SFTP_PACKET *packet = NULL; ssh_buffer reply = NULL; - u32 version; + uint32_t version; sftp_enter_function(); @@ -196,15 +196,15 @@ void sftp_free(SFTP_SESSION *sftp){ SAFE_FREE(sftp); } -int sftp_packet_write(SFTP_SESSION *sftp,u8 type, ssh_buffer payload){ +int sftp_packet_write(SFTP_SESSION *sftp, uint8_t type, ssh_buffer payload){ int size; - if (buffer_prepend_data(payload, &type, sizeof(u8)) < 0) { + if (buffer_prepend_data(payload, &type, sizeof(uint8_t)) < 0) { return -1; } size = htonl(buffer_get_len(payload)); - if (buffer_prepend_data(payload, &size, sizeof(u32)) < 0) { + if (buffer_prepend_data(payload, &size, sizeof(uint32_t)) < 0) { return -1; } @@ -212,7 +212,7 @@ int sftp_packet_write(SFTP_SESSION *sftp,u8 type, ssh_buffer payload){ buffer_get_len(payload)); if (size < 0) { return -1; - } else if((u32) size != buffer_get_len(payload)) { + } else if((uint32_t) size != buffer_get_len(payload)) { ssh_log(sftp->session, SSH_LOG_PACKET, "Had to write %d bytes, wrote only %d", buffer_get_len(payload), @@ -224,7 +224,7 @@ int sftp_packet_write(SFTP_SESSION *sftp,u8 type, ssh_buffer payload){ SFTP_PACKET *sftp_packet_read(SFTP_SESSION *sftp) { SFTP_PACKET *packet = NULL; - u32 size; + uint32_t size; sftp_enter_function(); @@ -353,7 +353,7 @@ static SFTP_MESSAGE *sftp_get_message(SFTP_PACKET *packet) { return NULL; } - if (buffer_get_u32(packet->payload, &msg->id) != sizeof(u32)) { + if (buffer_get_u32(packet->payload, &msg->id) != sizeof(uint32_t)) { ssh_set_error(packet->sftp->session, SSH_FATAL, "Invalid packet %d: no ID", packet->type); sftp_message_free(msg); @@ -423,7 +423,7 @@ int sftp_init(SFTP_SESSION *sftp) { ssh_string ext_data_s = NULL; char *ext_name = NULL; char *ext_data = NULL; - u32 version = htonl(LIBSFTP_VERSION); + uint32_t version = htonl(LIBSFTP_VERSION); sftp_enter_function(); @@ -544,7 +544,7 @@ static int sftp_enqueue(SFTP_SESSION *sftp, SFTP_MESSAGE *msg) { * Pulls of a message from the queue based on the ID. * Returns NULL if no message has been found. */ -static SFTP_MESSAGE *sftp_dequeue(SFTP_SESSION *sftp, u32 id){ +static SFTP_MESSAGE *sftp_dequeue(SFTP_SESSION *sftp, uint32_t id){ REQUEST_QUEUE *prev = NULL; REQUEST_QUEUE *queue; SFTP_MESSAGE *msg; @@ -582,7 +582,7 @@ static SFTP_MESSAGE *sftp_dequeue(SFTP_SESSION *sftp, u32 id){ * between them. * Returns a new ID ready to use in a request */ -static inline u32 sftp_get_new_id(SFTP_SESSION *session) { +static inline uint32_t sftp_get_new_id(SFTP_SESSION *session) { return ++session->id_counter; } @@ -674,7 +674,7 @@ SFTP_DIR *sftp_opendir(SFTP_SESSION *sftp, const char *path){ STATUS_MESSAGE *status; ssh_string path_s; ssh_buffer payload; - u32 id; + uint32_t id; payload = buffer_new(); if (payload == NULL) { @@ -762,7 +762,7 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_4(SFTP_SESSION *sftp, ssh_buffer buf, SFTP_ATTRIBUTES *attr; ssh_string owner = NULL; ssh_string group = NULL; - u32 flags = 0; + uint32_t flags = 0; int ok = 0; /* unused member variable */ @@ -938,7 +938,7 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, ssh_buffer buf, ssh_string longname = NULL; ssh_string name = NULL; SFTP_ATTRIBUTES *attr; - u32 flags = 0; + uint32_t flags = 0; int ok = 0; attr = malloc(sizeof(SFTP_ATTRIBUTES)); @@ -965,7 +965,7 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, ssh_buffer buf, string_free(longname); } - if (buffer_get_u32(buf, &flags) != sizeof(u32)) { + if (buffer_get_u32(buf, &flags) != sizeof(uint32_t)) { break; } flags = ntohl(flags); @@ -974,7 +974,7 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, ssh_buffer buf, "Flags: %.8lx\n", (long unsigned int) flags); if (flags & SSH_FILEXFER_ATTR_SIZE) { - if(buffer_get_u64(buf, &attr->size) != sizeof(u64)) { + if(buffer_get_u64(buf, &attr->size) != sizeof(uint64_t)) { break; } attr->size = ntohll(attr->size); @@ -984,10 +984,10 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, ssh_buffer buf, } if (flags & SSH_FILEXFER_ATTR_UIDGID) { - if (buffer_get_u32(buf, &attr->uid) != sizeof(u32)) { + if (buffer_get_u32(buf, &attr->uid) != sizeof(uint32_t)) { break; } - if (buffer_get_u32(buf, &attr->gid) != sizeof(u32)) { + if (buffer_get_u32(buf, &attr->gid) != sizeof(uint32_t)) { break; } attr->uid = ntohl(attr->uid); @@ -995,7 +995,7 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, ssh_buffer buf, } if (flags & SSH_FILEXFER_ATTR_PERMISSIONS) { - if (buffer_get_u32(buf, &attr->permissions) != sizeof(u32)) { + if (buffer_get_u32(buf, &attr->permissions) != sizeof(uint32_t)) { break; } attr->permissions = ntohl(attr->permissions); @@ -1026,18 +1026,18 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, ssh_buffer buf, } if (flags & SSH_FILEXFER_ATTR_ACMODTIME) { - if (buffer_get_u32(buf, &attr->atime) != sizeof(u32)) { + if (buffer_get_u32(buf, &attr->atime) != sizeof(uint32_t)) { break; } attr->atime = ntohl(attr->atime); - if (buffer_get_u32(buf, &attr->mtime) != sizeof(u32)) { + if (buffer_get_u32(buf, &attr->mtime) != sizeof(uint32_t)) { break; } attr->mtime = ntohl(attr->mtime); } if (flags & SSH_FILEXFER_ATTR_EXTENDED) { - if (buffer_get_u32(buf, &attr->extended_count) != sizeof(u32)) { + if (buffer_get_u32(buf, &attr->extended_count) != sizeof(uint32_t)) { break; } @@ -1076,7 +1076,7 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, ssh_buffer buf, /* FIXME is this really needed as a public function? */ int buffer_add_attributes(ssh_buffer buffer, SFTP_ATTRIBUTES *attr) { - u32 flags = (attr ? attr->flags : 0); + uint32_t flags = (attr ? attr->flags : 0); flags &= (SSH_FILEXFER_ATTR_SIZE | SSH_FILEXFER_ATTR_UIDGID | SSH_FILEXFER_ATTR_PERMISSIONS | SSH_FILEXFER_ATTR_ACMODTIME); @@ -1144,7 +1144,7 @@ SFTP_ATTRIBUTES *sftp_readdir(SFTP_SESSION *sftp, SFTP_DIR *dir) { STATUS_MESSAGE *status; SFTP_ATTRIBUTES *attr; ssh_buffer payload; - u32 id; + uint32_t id; if (dir->buffer == NULL) { payload = buffer_new(); @@ -1267,7 +1267,7 @@ static int sftp_handle_close(SFTP_SESSION *sftp, ssh_string handle) { STATUS_MESSAGE *status; SFTP_MESSAGE *msg = NULL; ssh_buffer buffer = NULL; - u32 id; + uint32_t id; buffer = buffer_new(); if (buffer == NULL) { @@ -1368,8 +1368,8 @@ SFTP_FILE *sftp_open(SFTP_SESSION *sftp, const char *file, int flags, SFTP_FILE *handle; ssh_string filename; ssh_buffer buffer; - u32 sftp_flags = 0; - u32 id; + uint32_t sftp_flags = 0; + uint32_t id; buffer = buffer_new(); if (buffer == NULL) { @@ -1553,10 +1553,10 @@ ssize_t sftp_read(SFTP_FILE *handle, void *buf, size_t count) { } /* Start an asynchronous read from a file using an opened sftp file handle. */ -int sftp_async_read_begin(SFTP_FILE *file, u32 len){ +int sftp_async_read_begin(SFTP_FILE *file, uint32_t len){ SFTP_SESSION *sftp = file->sftp; ssh_buffer buffer; - u32 id; + uint32_t id; sftp_enter_function(); @@ -1583,13 +1583,13 @@ int sftp_async_read_begin(SFTP_FILE *file, u32 len){ } /* Wait for an asynchronous read to complete and save the data. */ -int sftp_async_read(SFTP_FILE *file, void *data, u32 size, u32 id){ +int sftp_async_read(SFTP_FILE *file, void *data, uint32_t size, uint32_t id){ SFTP_SESSION *sftp = file->sftp; SFTP_MESSAGE *msg = NULL; STATUS_MESSAGE *status; ssh_string datastring; int err = SSH_OK; - u32 len; + uint32_t len; sftp_enter_function(); @@ -1679,7 +1679,7 @@ ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count) { STATUS_MESSAGE *status; ssh_string datastring; ssh_buffer buffer; - u32 id; + uint32_t id; int len; int packetlen; @@ -1755,7 +1755,7 @@ ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count) { } /* Seek to a specific location in a file. */ -int sftp_seek(SFTP_FILE *file, u32 new_offset) { +int sftp_seek(SFTP_FILE *file, uint32_t new_offset) { if (file == NULL) { return -1; } @@ -1765,7 +1765,7 @@ int sftp_seek(SFTP_FILE *file, u32 new_offset) { return 0; } -int sftp_seek64(SFTP_FILE *file, u64 new_offset) { +int sftp_seek64(SFTP_FILE *file, uint64_t new_offset) { if (file == NULL) { return -1; } @@ -1781,7 +1781,7 @@ unsigned long sftp_tell(SFTP_FILE *file) { } /* Report current byte position in file. */ uint64_t sftp_tell64(SFTP_FILE *file) { - return (u64)file->offset; + return (uint64_t) file->offset; } /* Rewinds the position of the file pointer to the beginning of the file.*/ @@ -1800,7 +1800,7 @@ int sftp_unlink(SFTP_SESSION *sftp, const char *file) { SFTP_MESSAGE *msg = NULL; ssh_string filename; ssh_buffer buffer; - u32 id; + uint32_t id; buffer = buffer_new(); if (buffer == NULL) { @@ -1869,7 +1869,7 @@ int sftp_rmdir(SFTP_SESSION *sftp, const char *directory) { SFTP_MESSAGE *msg = NULL; ssh_string filename; ssh_buffer buffer; - u32 id; + uint32_t id; buffer = buffer_new(); if (buffer == NULL) { @@ -1938,7 +1938,7 @@ int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, mode_t mode) { SFTP_ATTRIBUTES attr; ssh_buffer buffer; ssh_string path; - u32 id; + uint32_t id; buffer = buffer_new(); if (buffer == NULL) { @@ -2026,7 +2026,7 @@ int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname) { ssh_buffer buffer; ssh_string oldpath; ssh_string newpath; - u32 id; + uint32_t id; buffer = buffer_new(); if (buffer == NULL) { @@ -2105,7 +2105,7 @@ int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname) { /* Code written by Nick */ /* Set file attributes on a file, directory or symbolic link. */ int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr) { - u32 id = sftp_get_new_id(sftp); + uint32_t id = sftp_get_new_id(sftp); ssh_buffer buffer = buffer_new(); ssh_string path = string_from_char(file); SFTP_MESSAGE *msg = NULL; @@ -2222,7 +2222,7 @@ int sftp_symlink(SFTP_SESSION *sftp, const char *target, const char *dest) { ssh_string target_s; ssh_string dest_s; ssh_buffer buffer; - u32 id; + uint32_t id; if (sftp == NULL || target == NULL || dest == NULL) { return -1; @@ -2306,8 +2306,8 @@ char *sftp_readlink(SFTP_SESSION *sftp, const char *path) { ssh_string link_s = NULL; ssh_buffer buffer; char *link; - u32 ignored; - u32 id; + uint32_t ignored; + uint32_t id; if (sftp == NULL || path == NULL) { return NULL; @@ -2381,8 +2381,8 @@ char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path) { ssh_string pathstr; ssh_buffer buffer; char *cname; - u32 ignored; - u32 id; + uint32_t ignored; + uint32_t id; if (sftp == NULL || path == NULL) { return NULL; @@ -2454,7 +2454,7 @@ static SFTP_ATTRIBUTES *sftp_xstat(SFTP_SESSION *sftp, const char *path, SFTP_MESSAGE *msg = NULL; ssh_string pathstr; ssh_buffer buffer; - u32 id; + uint32_t id; buffer = buffer_new(); if (buffer == NULL) { @@ -2518,7 +2518,7 @@ SFTP_ATTRIBUTES *sftp_fstat(SFTP_FILE *file) { STATUS_MESSAGE *status = NULL; SFTP_MESSAGE *msg = NULL; ssh_buffer buffer; - u32 id; + uint32_t id; buffer = buffer_new(); if (buffer == NULL) { diff --git a/libssh/sftpserver.c b/libssh/sftpserver.c index 9f3c7c9a..0423653f 100644 --- a/libssh/sftpserver.c +++ b/libssh/sftpserver.c @@ -362,7 +362,7 @@ int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg) { return 0; } -int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, u32 status, +int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, uint32_t status, const char *message) { ssh_buffer out; ssh_string s; @@ -422,7 +422,7 @@ int sftp_reply_data(SFTP_CLIENT_MESSAGE *msg, const void *data, int len) { */ ssh_string sftp_handle_alloc(SFTP_SESSION *sftp, void *info) { ssh_string ret; - u32 val; + uint32_t val; int i; if (sftp->handles == NULL) { @@ -449,24 +449,24 @@ ssh_string sftp_handle_alloc(SFTP_SESSION *sftp, void *info) { return NULL; } - memcpy(ret->string, &val, sizeof(u32)); + memcpy(ret->string, &val, sizeof(uint32_t)); sftp->handles[i] = info; return ret; } void *sftp_handle(SFTP_SESSION *sftp, ssh_string handle){ - u32 val; + uint32_t val; if (sftp->handles == NULL) { return NULL; } - if (string_len(handle) != sizeof(u32)) { + if (string_len(handle) != sizeof(uint32_t)) { return NULL; } - memcpy(&val, handle->string, sizeof(u32)); + memcpy(&val, handle->string, sizeof(uint32_t)); if (val > SFTP_HANDLES) { return NULL; diff --git a/libssh/socket.c b/libssh/socket.c index d1869bbe..5d5f27f9 100644 --- a/libssh/socket.c +++ b/libssh/socket.c @@ -182,7 +182,7 @@ int ssh_socket_is_open(struct socket *s) { /* \internal * \brief read len bytes from socket into buffer */ -static int ssh_socket_unbuffered_read(struct socket *s, void *buffer, u32 len) { +static int ssh_socket_unbuffered_read(struct socket *s, void *buffer, uint32_t len) { int rc = -1; if (s->data_except) { @@ -208,7 +208,7 @@ static int ssh_socket_unbuffered_read(struct socket *s, void *buffer, u32 len) { * \brief writes len bytes from buffer to socket */ static int ssh_socket_unbuffered_write(struct socket *s, const void *buffer, - u32 len) { + uint32_t len) { int w = -1; if (s->data_except) { @@ -256,10 +256,10 @@ void ssh_socket_fd_set(struct socket *s, fd_set *set, int *fd_max) { /** \internal * \brief reads blocking until len bytes have been read */ -int ssh_socket_completeread(struct socket *s, void *buffer, u32 len) { +int ssh_socket_completeread(struct socket *s, void *buffer, uint32_t len) { int r = -1; - u32 total = 0; - u32 toread = len; + uint32_t total = 0; + uint32_t toread = len; if(! ssh_socket_is_open(s)) { return SSH_ERROR; } @@ -285,7 +285,7 @@ int ssh_socket_completeread(struct socket *s, void *buffer, u32 len) { /** \internal * \brief Blocking write of len bytes */ -int ssh_socket_completewrite(struct socket *s, const void *buffer, u32 len) { +int ssh_socket_completewrite(struct socket *s, const void *buffer, uint32_t len) { SSH_SESSION *session = s->session; int written = -1; @@ -370,7 +370,7 @@ int ssh_socket_write(struct socket *s, const void *buffer, int len) { * \returns SSH_AGAIN need to call later for data * \returns SSH_ERROR error happened */ -int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session, u32 len) { +int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session, uint32_t len) { char buffer[4096] = {0}; char *buf = NULL; int except; @@ -446,7 +446,7 @@ int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session, u32 len) { return SSH_ERROR; } - if (buffer_add_data(s->in_buffer,buffer, (u32) r) < 0) { + if (buffer_add_data(s->in_buffer,buffer, (uint32_t) r) < 0) { leave_function(); return SSH_ERROR; } |