Switch completly to stdint types.

This commit is contained in:
Andreas Schneider
2009-07-25 23:19:41 +02:00
parent ba217dec1c
commit 28b5d0f875
16 changed files with 235 additions and 241 deletions

View File

@@ -49,12 +49,6 @@
#define TYPE_RSA 2 #define TYPE_RSA 2
#define TYPE_RSA1 3 #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 */ /* profiling constants. Don't touch them unless you know what you do */
#ifdef HAVE_LIBCRYPTO #ifdef HAVE_LIBCRYPTO
#define OPENSSL_BIGNUMS #define OPENSSL_BIGNUMS
@@ -179,7 +173,7 @@ void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len);
/* strings and buffers */ /* strings and buffers */
/* must be 32 bits number + immediatly our data */ /* must be 32 bits number + immediatly our data */
struct ssh_string_struct { struct ssh_string_struct {
u32 size; uint32_t size;
unsigned char string[MAX_PACKET_LEN]; unsigned char string[MAX_PACKET_LEN];
} }
#if !defined(__SUNPRO_C) #if !defined(__SUNPRO_C)
@@ -191,16 +185,16 @@ __attribute__ ((packed))
*/ */
struct ssh_buffer_struct { struct ssh_buffer_struct {
char *data; char *data;
u32 used; uint32_t used;
u32 allocated; uint32_t allocated;
u32 pos; uint32_t pos;
}; };
/* i should remove it one day */ /* i should remove it one day */
typedef struct packet_struct { typedef struct packet_struct {
int valid; int valid;
u32 len; uint32_t len;
u8 type; uint8_t type;
} PACKET; } PACKET;
typedef struct kex_struct { typedef struct kex_struct {
@@ -305,15 +299,15 @@ struct ssh_channel_struct {
struct ssh_channel_struct *prev; struct ssh_channel_struct *prev;
struct ssh_channel_struct *next; struct ssh_channel_struct *next;
SSH_SESSION *session; /* SSH_SESSION pointer */ SSH_SESSION *session; /* SSH_SESSION pointer */
u32 local_channel; uint32_t local_channel;
u32 local_window; uint32_t local_window;
int local_eof; int local_eof;
u32 local_maxpacket; uint32_t local_maxpacket;
u32 remote_channel; uint32_t remote_channel;
u32 remote_window; uint32_t remote_window;
int remote_eof; /* end of file received */ int remote_eof; /* end of file received */
u32 remote_maxpacket; uint32_t remote_maxpacket;
int open; /* shows if the channel is still opened */ int open; /* shows if the channel is still opened */
int delayed_close; int delayed_close;
ssh_buffer stdout_buffer; ssh_buffer stdout_buffer;
@@ -346,8 +340,8 @@ struct ssh_session_struct {
int protoversion; int protoversion;
int server; int server;
int client; int client;
u32 send_seq; uint32_t send_seq;
u32 recv_seq; uint32_t recv_seq;
/* status flags */ /* status flags */
int closed; int closed;
int closed_by_except; int closed_by_except;
@@ -406,7 +400,7 @@ struct ssh_session_struct {
}; };
struct ssh_kbdint_struct { struct ssh_kbdint_struct {
u32 nprompts; uint32_t nprompts;
char *name; char *name;
char *instruction; char *instruction;
char **prompts; char **prompts;
@@ -432,13 +426,13 @@ struct ssh_auth_request {
struct ssh_channel_request_open { struct ssh_channel_request_open {
int type; int type;
u32 sender; uint32_t sender;
u32 window; uint32_t window;
u32 packet_size; uint32_t packet_size;
char *originator; char *originator;
u16 orignator_port; uint16_t orignator_port;
char *destination; char *destination;
u16 destination_port; uint16_t destination_port;
}; };
struct ssh_service_request { struct ssh_service_request {
@@ -448,13 +442,13 @@ struct ssh_service_request {
struct ssh_channel_request { struct ssh_channel_request {
int type; int type;
ssh_channel channel; ssh_channel channel;
u8 want_reply; uint8_t want_reply;
/* pty-req type specifics */ /* pty-req type specifics */
char *TERM; char *TERM;
u32 width; uint32_t width;
u32 height; uint32_t height;
u32 pxwidth; uint32_t pxwidth;
u32 pxheight; uint32_t pxheight;
ssh_string modes; ssh_string modes;
/* env type request */ /* 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_is_open(struct socket *s);
int ssh_socket_fd_isset(struct socket *s, fd_set *set); 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); 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_completeread(struct socket *s, void *buffer, uint32_t len);
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);
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);
int ssh_socket_nonblocking_flush(struct socket *s); int ssh_socket_nonblocking_flush(struct socket *s);
int ssh_socket_blocking_flush(struct socket *s); int ssh_socket_blocking_flush(struct socket *s);
int ssh_socket_poll(struct socket *s, int *writeable, int *except); 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); ssh_string make_bignum_string(bignum num);
/* in crypt.c */ /* 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); int packet_decrypt(SSH_SESSION *session, void *packet,unsigned int len);
unsigned char *packet_encrypt(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*/ /* 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); ssh_channel channel_new(SSH_SESSION *session);
int channel_default_bufferize(ssh_channel channel, void *data, int len, int channel_default_bufferize(ssh_channel channel, void *data, int len,
int is_stderr); int is_stderr);
u32 ssh_channel_new_id(SSH_SESSION *session); uint32_t ssh_channel_new_id(SSH_SESSION *session);
ssh_channel ssh_channel_from_local(SSH_SESSION *session, u32 id); ssh_channel ssh_channel_from_local(SSH_SESSION *session, uint32_t id);
/* options.c */ /* options.c */
@@ -699,32 +693,32 @@ int ssh_options_default_known_hosts_file(SSH_OPTIONS *opt);
/* buffer.c */ /* buffer.c */
int buffer_add_ssh_string(ssh_buffer buffer, ssh_string string); int buffer_add_ssh_string(ssh_buffer buffer, ssh_string string);
int buffer_add_u8(ssh_buffer buffer, u8 data); int buffer_add_u8(ssh_buffer buffer, uint8_t data);
int buffer_add_u32(ssh_buffer buffer, u32 data); int buffer_add_u32(ssh_buffer buffer, uint32_t data);
int buffer_add_u64(ssh_buffer buffer, u64 data); int buffer_add_u64(ssh_buffer buffer, uint64_t data);
int buffer_add_data(ssh_buffer buffer, const void *data, u32 len); int buffer_add_data(ssh_buffer buffer, const void *data, uint32_t len);
int buffer_prepend_data(ssh_buffer buffer, const void *data, u32 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_add_buffer(ssh_buffer buffer, ssh_buffer source);
int buffer_reinit(ssh_buffer buffer); int buffer_reinit(ssh_buffer buffer);
/* buffer_get_rest returns a pointer to the current position into the buffer */ /* buffer_get_rest returns a pointer to the current position into the buffer */
void *buffer_get_rest(ssh_buffer buffer); void *buffer_get_rest(ssh_buffer buffer);
/* buffer_get_rest_len returns the number of bytes which can be read */ /* 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 */ /* buffer_read_*() returns the number of bytes read, except for ssh strings */
int buffer_get_u8(ssh_buffer buffer, u8 *data); int buffer_get_u8(ssh_buffer buffer, uint8_t *data);
int buffer_get_u32(ssh_buffer buffer, u32 *data); int buffer_get_u32(ssh_buffer buffer, uint32_t *data);
int buffer_get_u64(ssh_buffer buffer, u64 *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. */ /* 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); ssh_string buffer_get_ssh_string(ssh_buffer buffer);
/* gets a string out of a SSH-1 mpint */ /* gets a string out of a SSH-1 mpint */
ssh_string buffer_get_mpint(ssh_buffer buffer); ssh_string buffer_get_mpint(ssh_buffer buffer);
/* buffer_pass_bytes acts as if len bytes have been read (used for padding) */ /* buffer_pass_bytes acts as if len bytes have been read (used for padding) */
u32 buffer_pass_bytes_end(ssh_buffer buffer, u32 len); uint32_t buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len);
u32 buffer_pass_bytes(ssh_buffer buffer, u32 len); uint32_t buffer_pass_bytes(ssh_buffer buffer, uint32_t len);
/* in base64.c */ /* in base64.c */
ssh_buffer base64_to_bin(const char *source); ssh_buffer base64_to_bin(const char *source);
@@ -741,7 +735,7 @@ CRYPTO *crypto_new(void);
void crypto_free(CRYPTO *crypto); void crypto_free(CRYPTO *crypto);
/* crc32.c */ /* crc32.c */
u32 ssh_crc32(const char *buf, u32 len); uint32_t ssh_crc32(const char *buf, uint32_t len);
/* auth1.c */ /* auth1.c */
int ssh_userauth1_none(SSH_SESSION *session, const char *username); 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); int ssh_file_readaccess_ok(const char *file);
/* macro for byte ordering */ /* macro for byte ordering */
u64 ntohll(u64); uint64_t ntohll(uint64_t);
#define htonll(x) ntohll(x) #define htonll(x) ntohll(x)
/* list processing */ /* list processing */
@@ -812,7 +806,7 @@ int match_hostname(const char *host, const char *pattern, unsigned int len);
/* messages.c */ /* 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); int ssh_execute_message_callbacks(SSH_SESSION *session);
/* log.c */ /* log.c */

View File

@@ -56,25 +56,25 @@
(((x) == SSH_AGENT_FAILURE) || ((x) == SSH_COM_AGENT2_FAILURE) || \ (((x) == SSH_AGENT_FAILURE) || ((x) == SSH_COM_AGENT2_FAILURE) || \
((x) == SSH2_AGENT_FAILURE)) ((x) == SSH2_AGENT_FAILURE))
static u32 agent_get_u32(const void *vp) { static uint32_t agent_get_u32(const void *vp) {
const u8 *p = (const u8 *)vp; const uint8_t *p = (const uint8_t *)vp;
u32 v; uint32_t v;
v = (u32)p[0] << 24; v = (uint32_t)p[0] << 24;
v |= (u32)p[1] << 16; v |= (uint32_t)p[1] << 16;
v |= (u32)p[2] << 8; v |= (uint32_t)p[2] << 8;
v |= (u32)p[3]; v |= (uint32_t)p[3];
return v; return v;
} }
static void agent_put_u32(void *vp, u32 v) { static void agent_put_u32(void *vp, uint32_t v) {
u8 *p = (u8 *)vp; uint8_t *p = (uint8_t *)vp;
p[0] = (u8)(v >> 24) & 0xff; p[0] = (uint8_t)(v >> 24) & 0xff;
p[1] = (u8)(v >> 16) & 0xff; p[1] = (uint8_t)(v >> 16) & 0xff;
p[2] = (u8)(v >> 8) & 0xff; p[2] = (uint8_t)(v >> 8) & 0xff;
p[3] = (u8)v & 0xff; p[3] = (uint8_t)v & 0xff;
} }
static size_t atomicio(struct socket *s, void *buf, size_t n, int do_read) { 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, static int agent_talk(struct ssh_session_struct *session,
struct ssh_buffer_struct *request, struct ssh_buffer_struct *reply) { struct ssh_buffer_struct *request, struct ssh_buffer_struct *reply) {
u32 len = 0; uint32_t len = 0;
u8 payload[1024] = {0}; uint8_t payload[1024] = {0};
len = buffer_get_len(request); len = buffer_get_len(request);
ssh_log(session, SSH_LOG_PACKET, "agent_talk - len of request: %u", len); 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; ssh_buffer reply = NULL;
unsigned int type = 0; unsigned int type = 0;
unsigned int c1 = 0, c2 = 0; unsigned int c1 = 0, c2 = 0;
u8 buf[4] = {0}; uint8_t buf[4] = {0};
switch (session->version) { switch (session->version) {
case 1: case 1:
@@ -302,7 +302,7 @@ int agent_get_ident_count(struct ssh_session_struct *session) {
buffer_free(request); buffer_free(request);
/* get message type and verify the answer */ /* 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, ssh_log(session, SSH_LOG_PACKET,
"agent_ident_count - answer type: %d, expected answer: %d", "agent_ident_count - answer type: %d, expected answer: %d",
type, c2); type, c2);
@@ -314,7 +314,7 @@ int agent_get_ident_count(struct ssh_session_struct *session) {
return -1; return -1;
} }
buffer_get_u32(reply, (u32 *) buf); buffer_get_u32(reply, (uint32_t *) buf);
session->agent->count = agent_get_u32(buf); session->agent->count = agent_get_u32(buf);
ssh_log(session, SSH_LOG_PACKET, "agent_ident_count - count: %d", ssh_log(session, SSH_LOG_PACKET, "agent_ident_count - count: %d",
session->agent->count); session->agent->count);
@@ -403,7 +403,7 @@ ssh_string agent_sign_data(struct ssh_session_struct *session,
struct ssh_buffer_struct *reply = NULL; struct ssh_buffer_struct *reply = NULL;
int type = SSH2_AGENT_FAILURE; int type = SSH2_AGENT_FAILURE;
int flags = 0; int flags = 0;
u32 dlen = 0; uint32_t dlen = 0;
/* create blob from the pubkey */ /* create blob from the pubkey */
blob = publickey_to_string(pubkey); blob = publickey_to_string(pubkey);
@@ -451,7 +451,7 @@ ssh_string agent_sign_data(struct ssh_session_struct *session,
buffer_free(request); buffer_free(request);
/* check if reply is valid */ /* check if reply is valid */
if (buffer_get_u8(reply, (u8 *) &type) < 0) { if (buffer_get_u8(reply, (uint8_t *) &type) < 0) {
goto error; goto error;
} }
if (agent_failed(type)) { if (agent_failed(type)) {

View File

@@ -61,7 +61,7 @@ static int wait_auth_status(SSH_SESSION *session, int kbdint) {
ssh_string auth; ssh_string auth;
int rc = SSH_AUTH_ERROR; int rc = SSH_AUTH_ERROR;
int cont = 1; int cont = 1;
u8 partial = 0; uint8_t partial = 0;
enter_function(); 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 name; /* name of the "asking" window showed to client */
ssh_string instruction; ssh_string instruction;
ssh_string tmp; ssh_string tmp;
u32 nprompts; uint32_t nprompts;
u32 i; uint32_t i;
enter_function(); enter_function();
@@ -1253,7 +1253,7 @@ static int kbdauth_info_get(SSH_SESSION *session) {
static int kbdauth_send(SSH_SESSION *session) { static int kbdauth_send(SSH_SESSION *session) {
ssh_string answer = NULL; ssh_string answer = NULL;
int rc = SSH_AUTH_ERROR; int rc = SSH_AUTH_ERROR;
u32 i; uint32_t i;
enter_function(); enter_function();

View File

@@ -143,7 +143,7 @@ int buffer_reinit(struct ssh_buffer_struct *buffer) {
* \param data data pointer * \param data data pointer
* \param len length of data * \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); buffer_verify(buffer);
if (buffer->allocated < (buffer->used + len)) { if (buffer->allocated < (buffer->used + len)) {
if (realloc_buffer(buffer, buffer->used + len) < 0) { 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, int buffer_add_ssh_string(struct ssh_buffer_struct *buffer,
struct ssh_string_struct *string) { struct ssh_string_struct *string) {
u32 len = 0; uint32_t len = 0;
len = ntohl(string->size); 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; return -1;
} }
@@ -180,7 +180,7 @@ int buffer_add_ssh_string(struct ssh_buffer_struct *buffer,
* \param data 32 bits integer * \param data 32 bits integer
* \return 0 on success, -1 on error. * \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) { if (buffer_add_data(buffer, &data, sizeof(data)) < 0) {
return -1; return -1;
} }
@@ -194,7 +194,7 @@ int buffer_add_u32(struct ssh_buffer_struct *buffer,u32 data){
* \param data 64 bits integer * \param data 64 bits integer
* \return 0 on success, -1 on error. * \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) { if (buffer_add_data(buffer, &data, sizeof(data)) < 0) {
return -1; return -1;
} }
@@ -207,8 +207,8 @@ int buffer_add_u64(struct ssh_buffer_struct *buffer, u64 data){
* \param data 8 bits integer * \param data 8 bits integer
* \return 0 on success, -1 on error. * \return 0 on success, -1 on error.
*/ */
int buffer_add_u8(struct ssh_buffer_struct *buffer,u8 data){ int buffer_add_u8(struct ssh_buffer_struct *buffer,uint8_t data){
if (buffer_add_data(buffer, &data, sizeof(u8)) < 0) { if (buffer_add_data(buffer, &data, sizeof(uint8_t)) < 0) {
return -1; return -1;
} }
@@ -223,7 +223,7 @@ int buffer_add_u8(struct ssh_buffer_struct *buffer,u8 data){
* \return 0 on success, -1 on error. * \return 0 on success, -1 on error.
*/ */
int buffer_prepend_data(struct ssh_buffer_struct *buffer, const void *data, int buffer_prepend_data(struct ssh_buffer_struct *buffer, const void *data,
u32 len) { uint32_t len) {
buffer_verify(buffer); buffer_verify(buffer);
if (buffer->allocated < (buffer->used + len)) { if (buffer->allocated < (buffer->used + len)) {
if (realloc_buffer(buffer, buffer->used + len) < 0) { 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 * \return length of the buffer
* \see buffer_get() * \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; return buffer->used;
} }
@@ -289,7 +289,7 @@ u32 buffer_get_len(struct ssh_buffer_struct *buffer){
* \return length of the buffer * \return length of the buffer
* \see buffer_get_rest() * \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); buffer_verify(buffer);
return buffer->used - buffer->pos; 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 * \param len number of bytes to eat
* \return new size of the buffer * \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); buffer_verify(buffer);
if(buffer->used < buffer->pos+len) if(buffer->used < buffer->pos+len)
return 0; 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 * \param len number of bytes to remove from tail
* \return new size of the buffer * \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); buffer_verify(buffer);
if(buffer->used < buffer->pos + len) if(buffer->used < buffer->pos + len)
return 0; 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 0 if there is not enough data in buffer
* \returns len otherwise. * \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) if(buffer->pos+len>buffer->used)
return 0; /*no enough data in buffer */ return 0; /*no enough data in buffer */
memcpy(data,buffer->data+buffer->pos,len); 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 /** \internal
* \brief gets a 8 bits unsigned int out of the buffer. Adjusts the read pointer. * \brief gets a 8 bits unsigned int out of the buffer. Adjusts the read pointer.
* \param buffer Buffer to read * \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 0 if there is not enough data in buffer
* \returns 1 otherwise. * \returns 1 otherwise.
*/ */
int buffer_get_u8(struct ssh_buffer_struct *buffer, u8 *data){ int buffer_get_u8(struct ssh_buffer_struct *buffer, uint8_t *data){
return buffer_get_data(buffer,data,sizeof(u8)); return buffer_get_data(buffer,data,sizeof(uint8_t));
} }
/** \internal /** \internal
* \brief gets a 32 bits unsigned int out of the buffer. Adjusts the read pointer. * \brief gets a 32 bits unsigned int out of the buffer. Adjusts the read pointer.
* \param buffer Buffer to read * \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 0 if there is not enough data in buffer
* \returns 4 otherwise. * \returns 4 otherwise.
*/ */
int buffer_get_u32(struct ssh_buffer_struct *buffer, u32 *data){ int buffer_get_u32(struct ssh_buffer_struct *buffer, uint32_t *data){
return buffer_get_data(buffer,data,sizeof(u32)); return buffer_get_data(buffer,data,sizeof(uint32_t));
} }
/** \internal /** \internal
* \brief gets a 64 bits unsigned int out of the buffer. Adjusts the read pointer. * \brief gets a 64 bits unsigned int out of the buffer. Adjusts the read pointer.
* \param buffer Buffer to read * \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 0 if there is not enough data in buffer
* \returns 8 otherwise. * \returns 8 otherwise.
*/ */
int buffer_get_u64(struct ssh_buffer_struct *buffer, u64 *data){ int buffer_get_u64(struct ssh_buffer_struct *buffer, uint64_t *data){
return buffer_get_data(buffer,data,sizeof(u64)); return buffer_get_data(buffer,data,sizeof(uint64_t));
} }
/** \internal /** \internal
* \brief gets a SSH String out of the buffer. Adjusts the read pointer. * \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. * \returns NULL otherwise.
*/ */
struct ssh_string_struct *buffer_get_ssh_string(struct ssh_buffer_struct *buffer) { struct ssh_string_struct *buffer_get_ssh_string(struct ssh_buffer_struct *buffer) {
u32 stringlen; uint32_t stringlen;
u32 hostlen; uint32_t hostlen;
struct ssh_string_struct *str = NULL; struct ssh_string_struct *str = NULL;
if (buffer_get_u32(buffer, &stringlen) == 0) { 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) { struct ssh_string_struct *buffer_get_mpint(struct ssh_buffer_struct *buffer) {
u16 bits; uint16_t bits;
u32 len; uint32_t len;
struct ssh_string_struct *str = NULL; 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; return NULL;
} }
bits = ntohs(bits); bits = ntohs(bits);

View File

@@ -102,7 +102,7 @@ ssh_channel channel_new(SSH_SESSION *session) {
* *
* @return The new channel identifier. * @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); 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) { int maxpacket, ssh_buffer payload) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
ssh_string type = NULL; ssh_string type = NULL;
u32 tmp = 0; uint32_t tmp = 0;
enter_function(); enter_function();
@@ -198,7 +198,7 @@ static int channel_open(ssh_channel channel, const char *type_c, int window,
{ {
ssh_string error_s; ssh_string error_s;
char *error; char *error;
u32 code; uint32_t code;
buffer_get_u32(session->in_buffer, &tmp); buffer_get_u32(session->in_buffer, &tmp);
buffer_get_u32(session->in_buffer, &code); 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? */ /* 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 initchan = session->channels;
ssh_channel channel; 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) { 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(); enter_function();
@@ -288,9 +288,9 @@ error:
static ssh_channel channel_from_msg(SSH_SESSION *session) { static ssh_channel channel_from_msg(SSH_SESSION *session) {
ssh_channel channel; 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, ssh_set_error(session, SSH_FATAL,
"Getting channel from message: short read"); "Getting channel from message: short read");
return NULL; return NULL;
@@ -308,7 +308,7 @@ static ssh_channel channel_from_msg(SSH_SESSION *session) {
static void channel_rcv_change_window(SSH_SESSION *session) { static void channel_rcv_change_window(SSH_SESSION *session) {
ssh_channel channel; ssh_channel channel;
u32 bytes; uint32_t bytes;
int rc; int rc;
enter_function(); enter_function();
@@ -319,7 +319,7 @@ static void channel_rcv_change_window(SSH_SESSION *session) {
} }
rc = buffer_get_u32(session->in_buffer, &bytes); 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, ssh_log(session, SSH_LOG_PACKET,
"Error getting a window adjust message: invalid packet"); "Error getting a window adjust message: invalid packet");
leave_function(); leave_function();
@@ -356,7 +356,7 @@ static void channel_rcv_data(SSH_SESSION *session,int is_stderr) {
} }
if (is_stderr) { if (is_stderr) {
u32 ignore; uint32_t ignore;
/* uint32 data type code. we can ignore it */ /* uint32 data type code. we can ignore it */
buffer_get_u32(session->in_buffer, &ignore); buffer_get_u32(session->in_buffer, &ignore);
} }
@@ -471,7 +471,7 @@ static void channel_rcv_request(SSH_SESSION *session) {
ssh_channel channel; ssh_channel channel;
ssh_string request_s; ssh_string request_s;
char *request; char *request;
u32 status; uint32_t status;
enter_function(); enter_function();
@@ -496,7 +496,7 @@ static void channel_rcv_request(SSH_SESSION *session) {
return; return;
} }
buffer_get_u8(session->in_buffer, (u8 *) &status); buffer_get_u8(session->in_buffer, (uint8_t *) &status);
if (strcmp(request,"exit-status") == 0) { if (strcmp(request,"exit-status") == 0) {
SAFE_FREE(request); SAFE_FREE(request);
@@ -512,7 +512,7 @@ static void channel_rcv_request(SSH_SESSION *session) {
const char *core = "(core dumped)"; const char *core = "(core dumped)";
ssh_string signal_s; ssh_string signal_s;
char *signal; char *signal;
u8 i; uint8_t i;
SAFE_FREE(request); SAFE_FREE(request);
@@ -865,7 +865,7 @@ error:
* *
* @see channel_read() * @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; SSH_SESSION *session = channel->session;
int origlen = len; int origlen = len;
int effectivelen; int effectivelen;
@@ -1359,12 +1359,12 @@ error:
* *
* @return The number of bytes read, 0 on end of file or SSH_ERROR on 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) { int is_stderr) {
SSH_SESSION *session=channel->session; SSH_SESSION *session=channel->session;
ssh_buffer stdbuf = channel->stdout_buffer; ssh_buffer stdbuf = channel->stdout_buffer;
u32 maxread = count; uint32_t maxread = count;
u32 len; uint32_t len;
buffer_reinit(buffer); 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 * @warning The read function using a buffer has been renamed to
* channel_read_buffer(). * 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_SESSION *session = channel->session;
ssh_buffer stdbuf = channel->stdout_buffer; ssh_buffer stdbuf = channel->stdout_buffer;
u32 len; uint32_t len;
enter_function(); enter_function();
@@ -1566,10 +1566,10 @@ int channel_read(ssh_channel channel, void *dest, u32 count, int is_stderr) {
* *
* @see channel_is_eof() * @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) { int is_stderr) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
u32 to_read; uint32_t to_read;
int rc; int rc;
enter_function(); enter_function();

View File

@@ -230,7 +230,7 @@ static int channel_rcv_data1(SSH_SESSION *session, int is_stderr) {
static int channel_rcv_close1(SSH_SESSION *session) { static int channel_rcv_close1(SSH_SESSION *session) {
ssh_channel channel = session->channels; ssh_channel channel = session->channels;
u32 status; uint32_t status;
buffer_get_u32(session->in_buffer, &status); buffer_get_u32(session->in_buffer, &status);
/* /*

View File

@@ -23,7 +23,7 @@
#include "libssh/priv.h" #include "libssh/priv.h"
static u32 crc_table[] = { static uint32_t crc_table[] = {
0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
@@ -78,8 +78,8 @@ static u32 crc_table[] = {
0x2d02ef8dUL 0x2d02ef8dUL
}; };
u32 ssh_crc32(const char *buf, u32 len) { uint32_t ssh_crc32(const char *buf, uint32_t len) {
u32 ret = 0; uint32_t ret = 0;
while(len > 0) { while(len > 0) {
ret = crc_table[(ret ^ *buf) & 0xff] ^ (ret >> 8); ret = crc_table[(ret ^ *buf) & 0xff] ^ (ret >> 8);
--len; --len;

View File

@@ -39,8 +39,8 @@
#include "libssh/priv.h" #include "libssh/priv.h"
#include "libssh/crypto.h" #include "libssh/crypto.h"
u32 packet_decrypt_len(SSH_SESSION *session, char *crypted){ uint32_t packet_decrypt_len(SSH_SESSION *session, char *crypted){
u32 decrypted; uint32_t decrypted;
if (session->current_crypto) { if (session->current_crypto) {
if (packet_decrypt(session, crypted, if (packet_decrypt(session, crypted,
@@ -57,7 +57,7 @@ u32 packet_decrypt_len(SSH_SESSION *session, char *crypted){
return ntohl(decrypted); 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; struct crypto_struct *crypto = session->current_crypto->in_cipher;
char *out = NULL; char *out = NULL;
@@ -90,12 +90,12 @@ int packet_decrypt(SSH_SESSION *session, void *data,u32 len) {
return 0; 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; struct crypto_struct *crypto = NULL;
HMACCTX ctx = NULL; HMACCTX ctx = NULL;
char *out = NULL; char *out = NULL;
unsigned int finallen; unsigned int finallen;
u32 seq; uint32_t seq;
if (!session->current_crypto) { if (!session->current_crypto) {
return NULL; /* nothing to do here */ return NULL; /* nothing to do here */
@@ -132,7 +132,7 @@ unsigned char *packet_encrypt(SSH_SESSION *session, void *data, u32 len) {
SAFE_FREE(out); SAFE_FREE(out);
return NULL; 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_update(ctx,data,len);
hmac_final(ctx,session->current_crypto->hmacbuf,&finallen); hmac_final(ctx,session->current_crypto->hmacbuf,&finallen);
#ifdef DEBUG_CRYPTO #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}; unsigned char hmacbuf[EVP_MAX_MD_SIZE] = {0};
HMACCTX ctx; HMACCTX ctx;
unsigned int len; unsigned int len;
u32 seq; uint32_t seq;
ctx = hmac_init(session->current_crypto->decryptMAC, 20, HMAC_SHA1); ctx = hmac_init(session->current_crypto->decryptMAC, 20, HMAC_SHA1);
if (ctx == NULL) { if (ctx == NULL) {
@@ -188,7 +188,7 @@ int packet_hmac_verify(SSH_SESSION *session, ssh_buffer buffer,
seq = htonl(session->recv_seq); 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_update(ctx, buffer_get(buffer), buffer_get_len(buffer));
hmac_final(ctx, hmacbuf, &len); hmac_final(ctx, hmacbuf, &len);

View File

@@ -480,7 +480,7 @@ int make_sessionid(SSH_SESSION *session) {
ssh_buffer server_hash = NULL; ssh_buffer server_hash = NULL;
ssh_buffer client_hash = NULL; ssh_buffer client_hash = NULL;
ssh_buffer buf = NULL; ssh_buffer buf = NULL;
u32 len; uint32_t len;
int rc = SSH_ERROR; int rc = SSH_ERROR;
enter_function(); enter_function();

View File

@@ -616,12 +616,12 @@ int ssh_get_kex1(SSH_SESSION *session) {
ssh_string enc_session = NULL; ssh_string enc_session = NULL;
ssh_public_key srv = NULL; ssh_public_key srv = NULL;
ssh_public_key host = NULL; ssh_public_key host = NULL;
u32 server_bits; uint32_t server_bits;
u32 host_bits; uint32_t host_bits;
u32 protocol_flags; uint32_t protocol_flags;
u32 supported_ciphers_mask; uint32_t supported_ciphers_mask;
u32 supported_authentications_mask; uint32_t supported_authentications_mask;
u16 bits; uint16_t bits;
int rc = -1; int rc = -1;
int ko; int ko;
@@ -661,7 +661,7 @@ int ssh_get_kex1(SSH_SESSION *session) {
buffer_get_u32(session->in_buffer, &supported_ciphers_mask); buffer_get_u32(session->in_buffer, &supported_ciphers_mask);
ko = buffer_get_u32(session->in_buffer, &supported_authentications_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) { || !server_mod || !server_exp) {
ssh_log(session, SSH_LOG_RARE, "Invalid SSH_SMSG_PUBLIC_KEY packet"); ssh_log(session, SSH_LOG_RARE, "Invalid SSH_SMSG_PUBLIC_KEY packet");
ssh_set_error(session, SSH_FATAL, "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, string_len(enc_session));
bits = htons(bits); bits = htons(bits);
/* the encrypted mpint */ /* 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; goto error;
} }
if (buffer_add_data(session->out_buffer, enc_session->string, if (buffer_add_data(session->out_buffer, enc_session->string,

View File

@@ -193,7 +193,7 @@ static SSH_MESSAGE *handle_userauth_request(SSH_SESSION *session){
if (strcmp(method_c, "password") == 0) { if (strcmp(method_c, "password") == 0) {
ssh_string pass = NULL; ssh_string pass = NULL;
u8 tmp; uint8_t tmp;
msg->auth_request.method = SSH_AUTH_PASSWORD; msg->auth_request.method = SSH_AUTH_PASSWORD;
SAFE_FREE(method_c); SAFE_FREE(method_c);
@@ -337,7 +337,7 @@ static SSH_MESSAGE *handle_channel_request_open(SSH_SESSION *session) {
SSH_MESSAGE *msg = NULL; SSH_MESSAGE *msg = NULL;
ssh_string type = NULL; ssh_string type = NULL;
char *type_c = NULL; char *type_c = NULL;
u32 sender, window, packet; uint32_t sender, window, packet;
enter_function(); enter_function();
@@ -481,8 +481,8 @@ static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session) {
SSH_MESSAGE *msg = NULL; SSH_MESSAGE *msg = NULL;
ssh_string type = NULL; ssh_string type = NULL;
char *type_c = NULL; char *type_c = NULL;
u32 channel; uint32_t channel;
u8 want_reply; uint8_t want_reply;
enter_function(); 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) { int ssh_message_channel_request_reply_success(SSH_MESSAGE *msg) {
u32 channel; uint32_t channel;
if (msg == NULL) { if (msg == NULL) {
return SSH_ERROR; 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) { static int ssh_message_channel_request_reply_default(SSH_MESSAGE *msg) {
u32 channel; uint32_t channel;
if (msg->channel_request.want_reply) { if (msg->channel_request.want_reply) {
channel = msg->channel_request.channel->remote_channel; 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; 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; SSH_MESSAGE *msg=NULL;
enter_function(); enter_function();
switch(packettype) { switch(packettype) {
@@ -807,7 +807,7 @@ void ssh_message_free(SSH_MESSAGE *msg){
* \param type packet type * \param type packet type
* \returns nothing * \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); SSH_MESSAGE *msg=ssh_message_retrieve(session,type);
if(msg){ if(msg){
if(!session->ssh_message_list){ if(!session->ssh_message_list){

View File

@@ -104,16 +104,16 @@ int ssh_file_readaccess_ok(const char *file) {
return 1; return 1;
} }
u64 ntohll(u64 a) { uint64_t ntohll(uint64_t a) {
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
return a; return a;
#else #else
u32 low = a & 0xffffffff; uint32_t low = a & 0xffffffff;
u32 high = a >> 32 ; uint32_t high = a >> 32 ;
low = ntohl(low); low = ntohl(low);
high = ntohl(high); high = ntohl(high);
return ((((u64) low) << 32) | ( high)); return ((((uint64_t) low) << 32) | ( high));
#endif #endif
} }

View File

@@ -58,8 +58,8 @@ static int packet_read2(SSH_SESSION *session) {
int to_be_read; int to_be_read;
int rc = SSH_ERROR; int rc = SSH_ERROR;
u32 len; uint32_t len;
u8 padding; uint8_t padding;
enter_function(); enter_function();
@@ -103,7 +103,7 @@ static int packet_read2(SSH_SESSION *session) {
goto error; goto error;
} }
to_be_read = len - blocksize + sizeof(u32); to_be_read = len - blocksize + sizeof(uint32_t);
if (to_be_read < 0) { if (to_be_read < 0) {
/* remote sshd sends invalid sizes? */ /* remote sshd sends invalid sizes? */
ssh_set_error(session, SSH_FATAL, ssh_set_error(session, SSH_FATAL,
@@ -116,7 +116,7 @@ static int packet_read2(SSH_SESSION *session) {
session->packet_state = PACKET_STATE_SIZEREAD; session->packet_state = PACKET_STATE_SIZEREAD;
case PACKET_STATE_SIZEREAD: case PACKET_STATE_SIZEREAD:
len = session->in_packet.len; 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 is zero, the whole packet was blocksize bytes. */
if (to_be_read != 0) { if (to_be_read != 0) {
rc = ssh_socket_wait_for_data(session->socket,session,to_be_read); 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 */ /* pass the size which has been processed before */
if (buffer_get_u8(session->in_buffer, &padding) == 0) { if (buffer_get_u8(session->in_buffer, &padding) == 0) {
@@ -220,9 +220,9 @@ static int packet_read1(SSH_SESSION *session) {
void *packet = NULL; void *packet = NULL;
int rc = SSH_ERROR; int rc = SSH_ERROR;
int to_be_read; int to_be_read;
u32 padding; uint32_t padding;
u32 crc; uint32_t crc;
u32 len; uint32_t len;
enter_function(); enter_function();
@@ -436,12 +436,12 @@ static int packet_write(SSH_SESSION *session) {
static int packet_send2(SSH_SESSION *session) { static int packet_send2(SSH_SESSION *session) {
unsigned int blocksize = (session->current_crypto ? unsigned int blocksize = (session->current_crypto ?
session->current_crypto->out_cipher->blocksize : 8); 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; unsigned char *hmac = NULL;
char padstring[32] = {0}; char padstring[32] = {0};
int rc = SSH_ERROR; int rc = SSH_ERROR;
u32 finallen; uint32_t finallen;
u8 padding; uint8_t padding;
enter_function(); enter_function();
@@ -473,10 +473,10 @@ static int packet_send2(SSH_SESSION *session) {
"%d bytes after comp + %d padding bytes = %lu bytes packet", "%d bytes after comp + %d padding bytes = %lu bytes packet",
currentlen, padding, (long unsigned int) ntohl(finallen)); 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; 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; goto error;
} }
if (buffer_add_data(session->out_buffer, padstring, padding) < 0) { if (buffer_add_data(session->out_buffer, padstring, padding) < 0) {
@@ -506,12 +506,12 @@ error:
static int packet_send1(SSH_SESSION *session) { static int packet_send1(SSH_SESSION *session) {
unsigned int blocksize = (session->current_crypto ? unsigned int blocksize = (session->current_crypto ?
session->current_crypto->out_cipher->blocksize : 8); 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}; char padstring[32] = {0};
int rc = SSH_ERROR; int rc = SSH_ERROR;
u32 finallen; uint32_t finallen;
u32 crc; uint32_t crc;
u8 padding; uint8_t padding;
enter_function(); enter_function();
ssh_log(session,SSH_LOG_PACKET,"Sending a %d bytes long packet",currentlen); 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) { if (buffer_prepend_data(session->out_buffer, &padstring, padding) < 0) {
goto error; 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; goto error;
} }
crc = ssh_crc32(buffer_get(session->out_buffer) + sizeof(u32), crc = ssh_crc32(buffer_get(session->out_buffer) + sizeof(uint32_t),
buffer_get_len(session->out_buffer) - sizeof(u32)); buffer_get_len(session->out_buffer) - sizeof(uint32_t));
if (buffer_add_u32(session->out_buffer, ntohl(crc)) < 0) { if (buffer_add_u32(session->out_buffer, ntohl(crc)) < 0) {
goto error; goto error;
@@ -557,8 +557,8 @@ static int packet_send1(SSH_SESSION *session) {
buffer_get_len(session->out_buffer)); buffer_get_len(session->out_buffer));
#endif #endif
packet_encrypt(session, buffer_get(session->out_buffer) + sizeof(u32), packet_encrypt(session, buffer_get(session->out_buffer) + sizeof(uint32_t),
buffer_get_len(session->out_buffer) - sizeof(u32)); buffer_get_len(session->out_buffer) - sizeof(uint32_t));
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("encrypted packet",buffer_get(session->out_buffer), 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) { void packet_parse(SSH_SESSION *session) {
ssh_string error_s = NULL; ssh_string error_s = NULL;
char *error = NULL; char *error = NULL;
u32 type = session->in_packet.type; uint32_t type = session->in_packet.type;
u32 tmp; uint32_t tmp;
#ifdef HAVE_SSH1 #ifdef HAVE_SSH1
if (session->version == 1) { if (session->version == 1) {

View File

@@ -112,7 +112,7 @@ int sftp_server_init(SFTP_SESSION *sftp){
ssh_session session = sftp->session; ssh_session session = sftp->session;
SFTP_PACKET *packet = NULL; SFTP_PACKET *packet = NULL;
ssh_buffer reply = NULL; ssh_buffer reply = NULL;
u32 version; uint32_t version;
sftp_enter_function(); sftp_enter_function();
@@ -196,15 +196,15 @@ void sftp_free(SFTP_SESSION *sftp){
SAFE_FREE(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; int size;
if (buffer_prepend_data(payload, &type, sizeof(u8)) < 0) { if (buffer_prepend_data(payload, &type, sizeof(uint8_t)) < 0) {
return -1; return -1;
} }
size = htonl(buffer_get_len(payload)); 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; return -1;
} }
@@ -212,7 +212,7 @@ int sftp_packet_write(SFTP_SESSION *sftp,u8 type, ssh_buffer payload){
buffer_get_len(payload)); buffer_get_len(payload));
if (size < 0) { if (size < 0) {
return -1; 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, ssh_log(sftp->session, SSH_LOG_PACKET,
"Had to write %d bytes, wrote only %d", "Had to write %d bytes, wrote only %d",
buffer_get_len(payload), 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 *sftp_packet_read(SFTP_SESSION *sftp) {
SFTP_PACKET *packet = NULL; SFTP_PACKET *packet = NULL;
u32 size; uint32_t size;
sftp_enter_function(); sftp_enter_function();
@@ -353,7 +353,7 @@ static SFTP_MESSAGE *sftp_get_message(SFTP_PACKET *packet) {
return NULL; 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, ssh_set_error(packet->sftp->session, SSH_FATAL,
"Invalid packet %d: no ID", packet->type); "Invalid packet %d: no ID", packet->type);
sftp_message_free(msg); sftp_message_free(msg);
@@ -423,7 +423,7 @@ int sftp_init(SFTP_SESSION *sftp) {
ssh_string ext_data_s = NULL; ssh_string ext_data_s = NULL;
char *ext_name = NULL; char *ext_name = NULL;
char *ext_data = NULL; char *ext_data = NULL;
u32 version = htonl(LIBSFTP_VERSION); uint32_t version = htonl(LIBSFTP_VERSION);
sftp_enter_function(); 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. * Pulls of a message from the queue based on the ID.
* Returns NULL if no message has been found. * 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 *prev = NULL;
REQUEST_QUEUE *queue; REQUEST_QUEUE *queue;
SFTP_MESSAGE *msg; SFTP_MESSAGE *msg;
@@ -582,7 +582,7 @@ static SFTP_MESSAGE *sftp_dequeue(SFTP_SESSION *sftp, u32 id){
* between them. * between them.
* Returns a new ID ready to use in a request * 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; return ++session->id_counter;
} }
@@ -674,7 +674,7 @@ SFTP_DIR *sftp_opendir(SFTP_SESSION *sftp, const char *path){
STATUS_MESSAGE *status; STATUS_MESSAGE *status;
ssh_string path_s; ssh_string path_s;
ssh_buffer payload; ssh_buffer payload;
u32 id; uint32_t id;
payload = buffer_new(); payload = buffer_new();
if (payload == NULL) { if (payload == NULL) {
@@ -762,7 +762,7 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_4(SFTP_SESSION *sftp, ssh_buffer buf,
SFTP_ATTRIBUTES *attr; SFTP_ATTRIBUTES *attr;
ssh_string owner = NULL; ssh_string owner = NULL;
ssh_string group = NULL; ssh_string group = NULL;
u32 flags = 0; uint32_t flags = 0;
int ok = 0; int ok = 0;
/* unused member variable */ /* 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 longname = NULL;
ssh_string name = NULL; ssh_string name = NULL;
SFTP_ATTRIBUTES *attr; SFTP_ATTRIBUTES *attr;
u32 flags = 0; uint32_t flags = 0;
int ok = 0; int ok = 0;
attr = malloc(sizeof(SFTP_ATTRIBUTES)); 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); string_free(longname);
} }
if (buffer_get_u32(buf, &flags) != sizeof(u32)) { if (buffer_get_u32(buf, &flags) != sizeof(uint32_t)) {
break; break;
} }
flags = ntohl(flags); 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); "Flags: %.8lx\n", (long unsigned int) flags);
if (flags & SSH_FILEXFER_ATTR_SIZE) { 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; break;
} }
attr->size = ntohll(attr->size); 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 (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; break;
} }
if (buffer_get_u32(buf, &attr->gid) != sizeof(u32)) { if (buffer_get_u32(buf, &attr->gid) != sizeof(uint32_t)) {
break; break;
} }
attr->uid = ntohl(attr->uid); 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 (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; break;
} }
attr->permissions = ntohl(attr->permissions); 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 (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; break;
} }
attr->atime = ntohl(attr->atime); 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; break;
} }
attr->mtime = ntohl(attr->mtime); attr->mtime = ntohl(attr->mtime);
} }
if (flags & SSH_FILEXFER_ATTR_EXTENDED) { 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; 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? */ /* FIXME is this really needed as a public function? */
int buffer_add_attributes(ssh_buffer buffer, SFTP_ATTRIBUTES *attr) { 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 | flags &= (SSH_FILEXFER_ATTR_SIZE | SSH_FILEXFER_ATTR_UIDGID |
SSH_FILEXFER_ATTR_PERMISSIONS | SSH_FILEXFER_ATTR_ACMODTIME); 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; STATUS_MESSAGE *status;
SFTP_ATTRIBUTES *attr; SFTP_ATTRIBUTES *attr;
ssh_buffer payload; ssh_buffer payload;
u32 id; uint32_t id;
if (dir->buffer == NULL) { if (dir->buffer == NULL) {
payload = buffer_new(); payload = buffer_new();
@@ -1267,7 +1267,7 @@ static int sftp_handle_close(SFTP_SESSION *sftp, ssh_string handle) {
STATUS_MESSAGE *status; STATUS_MESSAGE *status;
SFTP_MESSAGE *msg = NULL; SFTP_MESSAGE *msg = NULL;
ssh_buffer buffer = NULL; ssh_buffer buffer = NULL;
u32 id; uint32_t id;
buffer = buffer_new(); buffer = buffer_new();
if (buffer == NULL) { if (buffer == NULL) {
@@ -1368,8 +1368,8 @@ SFTP_FILE *sftp_open(SFTP_SESSION *sftp, const char *file, int flags,
SFTP_FILE *handle; SFTP_FILE *handle;
ssh_string filename; ssh_string filename;
ssh_buffer buffer; ssh_buffer buffer;
u32 sftp_flags = 0; uint32_t sftp_flags = 0;
u32 id; uint32_t id;
buffer = buffer_new(); buffer = buffer_new();
if (buffer == NULL) { 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. */ /* 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; SFTP_SESSION *sftp = file->sftp;
ssh_buffer buffer; ssh_buffer buffer;
u32 id; uint32_t id;
sftp_enter_function(); 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. */ /* 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_SESSION *sftp = file->sftp;
SFTP_MESSAGE *msg = NULL; SFTP_MESSAGE *msg = NULL;
STATUS_MESSAGE *status; STATUS_MESSAGE *status;
ssh_string datastring; ssh_string datastring;
int err = SSH_OK; int err = SSH_OK;
u32 len; uint32_t len;
sftp_enter_function(); sftp_enter_function();
@@ -1679,7 +1679,7 @@ ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count) {
STATUS_MESSAGE *status; STATUS_MESSAGE *status;
ssh_string datastring; ssh_string datastring;
ssh_buffer buffer; ssh_buffer buffer;
u32 id; uint32_t id;
int len; int len;
int packetlen; 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. */ /* 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) { if (file == NULL) {
return -1; return -1;
} }
@@ -1765,7 +1765,7 @@ int sftp_seek(SFTP_FILE *file, u32 new_offset) {
return 0; return 0;
} }
int sftp_seek64(SFTP_FILE *file, u64 new_offset) { int sftp_seek64(SFTP_FILE *file, uint64_t new_offset) {
if (file == NULL) { if (file == NULL) {
return -1; return -1;
} }
@@ -1781,7 +1781,7 @@ unsigned long sftp_tell(SFTP_FILE *file) {
} }
/* Report current byte position in file. */ /* Report current byte position in file. */
uint64_t sftp_tell64(SFTP_FILE *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.*/ /* 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; SFTP_MESSAGE *msg = NULL;
ssh_string filename; ssh_string filename;
ssh_buffer buffer; ssh_buffer buffer;
u32 id; uint32_t id;
buffer = buffer_new(); buffer = buffer_new();
if (buffer == NULL) { if (buffer == NULL) {
@@ -1869,7 +1869,7 @@ int sftp_rmdir(SFTP_SESSION *sftp, const char *directory) {
SFTP_MESSAGE *msg = NULL; SFTP_MESSAGE *msg = NULL;
ssh_string filename; ssh_string filename;
ssh_buffer buffer; ssh_buffer buffer;
u32 id; uint32_t id;
buffer = buffer_new(); buffer = buffer_new();
if (buffer == NULL) { if (buffer == NULL) {
@@ -1938,7 +1938,7 @@ int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, mode_t mode) {
SFTP_ATTRIBUTES attr; SFTP_ATTRIBUTES attr;
ssh_buffer buffer; ssh_buffer buffer;
ssh_string path; ssh_string path;
u32 id; uint32_t id;
buffer = buffer_new(); buffer = buffer_new();
if (buffer == NULL) { if (buffer == NULL) {
@@ -2026,7 +2026,7 @@ int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname) {
ssh_buffer buffer; ssh_buffer buffer;
ssh_string oldpath; ssh_string oldpath;
ssh_string newpath; ssh_string newpath;
u32 id; uint32_t id;
buffer = buffer_new(); buffer = buffer_new();
if (buffer == NULL) { if (buffer == NULL) {
@@ -2105,7 +2105,7 @@ int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname) {
/* Code written by Nick */ /* Code written by Nick */
/* Set file attributes on a file, directory or symbolic link. */ /* Set file attributes on a file, directory or symbolic link. */
int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr) { 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_buffer buffer = buffer_new();
ssh_string path = string_from_char(file); ssh_string path = string_from_char(file);
SFTP_MESSAGE *msg = NULL; 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 target_s;
ssh_string dest_s; ssh_string dest_s;
ssh_buffer buffer; ssh_buffer buffer;
u32 id; uint32_t id;
if (sftp == NULL || target == NULL || dest == NULL) { if (sftp == NULL || target == NULL || dest == NULL) {
return -1; return -1;
@@ -2306,8 +2306,8 @@ char *sftp_readlink(SFTP_SESSION *sftp, const char *path) {
ssh_string link_s = NULL; ssh_string link_s = NULL;
ssh_buffer buffer; ssh_buffer buffer;
char *link; char *link;
u32 ignored; uint32_t ignored;
u32 id; uint32_t id;
if (sftp == NULL || path == NULL) { if (sftp == NULL || path == NULL) {
return NULL; return NULL;
@@ -2381,8 +2381,8 @@ char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path) {
ssh_string pathstr; ssh_string pathstr;
ssh_buffer buffer; ssh_buffer buffer;
char *cname; char *cname;
u32 ignored; uint32_t ignored;
u32 id; uint32_t id;
if (sftp == NULL || path == NULL) { if (sftp == NULL || path == NULL) {
return NULL; return NULL;
@@ -2454,7 +2454,7 @@ static SFTP_ATTRIBUTES *sftp_xstat(SFTP_SESSION *sftp, const char *path,
SFTP_MESSAGE *msg = NULL; SFTP_MESSAGE *msg = NULL;
ssh_string pathstr; ssh_string pathstr;
ssh_buffer buffer; ssh_buffer buffer;
u32 id; uint32_t id;
buffer = buffer_new(); buffer = buffer_new();
if (buffer == NULL) { if (buffer == NULL) {
@@ -2518,7 +2518,7 @@ SFTP_ATTRIBUTES *sftp_fstat(SFTP_FILE *file) {
STATUS_MESSAGE *status = NULL; STATUS_MESSAGE *status = NULL;
SFTP_MESSAGE *msg = NULL; SFTP_MESSAGE *msg = NULL;
ssh_buffer buffer; ssh_buffer buffer;
u32 id; uint32_t id;
buffer = buffer_new(); buffer = buffer_new();
if (buffer == NULL) { if (buffer == NULL) {

View File

@@ -362,7 +362,7 @@ int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg) {
return 0; 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) { const char *message) {
ssh_buffer out; ssh_buffer out;
ssh_string s; 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 sftp_handle_alloc(SFTP_SESSION *sftp, void *info) {
ssh_string ret; ssh_string ret;
u32 val; uint32_t val;
int i; int i;
if (sftp->handles == NULL) { if (sftp->handles == NULL) {
@@ -449,24 +449,24 @@ ssh_string sftp_handle_alloc(SFTP_SESSION *sftp, void *info) {
return NULL; return NULL;
} }
memcpy(ret->string, &val, sizeof(u32)); memcpy(ret->string, &val, sizeof(uint32_t));
sftp->handles[i] = info; sftp->handles[i] = info;
return ret; return ret;
} }
void *sftp_handle(SFTP_SESSION *sftp, ssh_string handle){ void *sftp_handle(SFTP_SESSION *sftp, ssh_string handle){
u32 val; uint32_t val;
if (sftp->handles == NULL) { if (sftp->handles == NULL) {
return NULL; return NULL;
} }
if (string_len(handle) != sizeof(u32)) { if (string_len(handle) != sizeof(uint32_t)) {
return NULL; return NULL;
} }
memcpy(&val, handle->string, sizeof(u32)); memcpy(&val, handle->string, sizeof(uint32_t));
if (val > SFTP_HANDLES) { if (val > SFTP_HANDLES) {
return NULL; return NULL;

View File

@@ -182,7 +182,7 @@ int ssh_socket_is_open(struct socket *s) {
/* \internal /* \internal
* \brief read len bytes from socket into buffer * \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; int rc = -1;
if (s->data_except) { 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 * \brief writes len bytes from buffer to socket
*/ */
static int ssh_socket_unbuffered_write(struct socket *s, const void *buffer, static int ssh_socket_unbuffered_write(struct socket *s, const void *buffer,
u32 len) { uint32_t len) {
int w = -1; int w = -1;
if (s->data_except) { if (s->data_except) {
@@ -256,10 +256,10 @@ void ssh_socket_fd_set(struct socket *s, fd_set *set, int *fd_max) {
/** \internal /** \internal
* \brief reads blocking until len bytes have been read * \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; int r = -1;
u32 total = 0; uint32_t total = 0;
u32 toread = len; uint32_t toread = len;
if(! ssh_socket_is_open(s)) { if(! ssh_socket_is_open(s)) {
return SSH_ERROR; return SSH_ERROR;
} }
@@ -285,7 +285,7 @@ int ssh_socket_completeread(struct socket *s, void *buffer, u32 len) {
/** \internal /** \internal
* \brief Blocking write of len bytes * \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; SSH_SESSION *session = s->session;
int written = -1; 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_AGAIN need to call later for data
* \returns SSH_ERROR error happened * \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 buffer[4096] = {0};
char *buf = NULL; char *buf = NULL;
int except; int except;
@@ -446,7 +446,7 @@ int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session, u32 len) {
return SSH_ERROR; 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(); leave_function();
return SSH_ERROR; return SSH_ERROR;
} }