diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2009-07-24 21:45:41 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2009-07-24 21:45:41 +0200 |
commit | 56ee212641e8f5a008224da103dce78e421eb4b6 (patch) | |
tree | 47b76a7dfcafe19303d0f72c2107c8581affa5fe /libssh | |
parent | 8f3891e968bad4b9fb06e92f5a893dd30a343677 (diff) | |
download | libssh-56ee212641e8f5a008224da103dce78e421eb4b6.tar.gz libssh-56ee212641e8f5a008224da103dce78e421eb4b6.tar.xz libssh-56ee212641e8f5a008224da103dce78e421eb4b6.zip |
Change all occurences of STRING * to ssh_string
Diffstat (limited to 'libssh')
-rw-r--r-- | libssh/agent.c | 2 | ||||
-rw-r--r-- | libssh/auth.c | 70 | ||||
-rw-r--r-- | libssh/channels.c | 22 | ||||
-rw-r--r-- | libssh/client.c | 12 | ||||
-rw-r--r-- | libssh/dh.c | 32 | ||||
-rw-r--r-- | libssh/kex.c | 34 | ||||
-rw-r--r-- | libssh/keyfiles.c | 48 | ||||
-rw-r--r-- | libssh/keys.c | 90 | ||||
-rw-r--r-- | libssh/messages.c | 22 | ||||
-rw-r--r-- | libssh/packet.c | 2 | ||||
-rw-r--r-- | libssh/server.c | 8 | ||||
-rw-r--r-- | libssh/sftp.c | 42 | ||||
-rw-r--r-- | libssh/sftpserver.c | 16 |
13 files changed, 200 insertions, 200 deletions
diff --git a/libssh/agent.c b/libssh/agent.c index b0bcbe4e..98a583c0 100644 --- a/libssh/agent.c +++ b/libssh/agent.c @@ -394,7 +394,7 @@ struct ssh_public_key_struct *agent_get_next_ident(struct ssh_session *session, return pubkey; } -STRING *agent_sign_data(struct ssh_session *session, +ssh_string agent_sign_data(struct ssh_session *session, struct ssh_buffer_struct *data, struct ssh_public_key_struct *pubkey) { struct ssh_string_struct *blob = NULL; diff --git a/libssh/auth.c b/libssh/auth.c index 20c8f007..8bb13e36 100644 --- a/libssh/auth.c +++ b/libssh/auth.c @@ -58,7 +58,7 @@ static int ask_userauth(SSH_SESSION *session) { static int wait_auth_status(SSH_SESSION *session, int kbdint) { char *auth_methods = NULL; - STRING *auth; + ssh_string auth; int rc = SSH_AUTH_ERROR; int cont = 1; u8 partial = 0; @@ -139,7 +139,7 @@ static int wait_auth_status(SSH_SESSION *session, int kbdint) { break; case SSH2_MSG_USERAUTH_BANNER: { - STRING *banner; + ssh_string banner; banner = buffer_get_ssh_string(session->in_buffer); if (banner == NULL) { @@ -201,9 +201,9 @@ int ssh_userauth_list(SSH_SESSION *session, const char *username) { * SSH_AUTH_SUCCESS: Authentication success */ int ssh_userauth_none(SSH_SESSION *session, const char *username) { - STRING *user = NULL; - STRING *service = NULL; - STRING *method = NULL; + ssh_string user = NULL; + ssh_string service = NULL; + ssh_string method = NULL; int rc = SSH_AUTH_ERROR; enter_function(); @@ -305,11 +305,11 @@ error: * @see ssh_userauth_pubkey() */ int ssh_userauth_offer_pubkey(SSH_SESSION *session, const char *username, - int type, STRING *publickey) { - STRING *user = NULL; - STRING *service = NULL; - STRING *method = NULL; - STRING *algo = NULL; + int type, ssh_string publickey) { + ssh_string user = NULL; + ssh_string service = NULL; + ssh_string method = NULL; + ssh_string algo = NULL; int rc = SSH_AUTH_ERROR; enter_function(); @@ -418,12 +418,12 @@ error: * @see ssh_userauth_offer_pubkey() */ int ssh_userauth_pubkey(SSH_SESSION *session, const char *username, - STRING *publickey, PRIVATE_KEY *privatekey) { - STRING *user = NULL; - STRING *service = NULL; - STRING *method = NULL; - STRING *algo = NULL; - STRING *sign = NULL; + ssh_string publickey, PRIVATE_KEY *privatekey) { + ssh_string user = NULL; + ssh_string service = NULL; + ssh_string method = NULL; + ssh_string algo = NULL; + ssh_string sign = NULL; int rc = SSH_AUTH_ERROR; enter_function(); @@ -538,12 +538,12 @@ error: */ int ssh_userauth_agent_pubkey(SSH_SESSION *session, const char *username, PUBLIC_KEY *publickey) { - STRING *user = NULL; - STRING *service = NULL; - STRING *method = NULL; - STRING *algo = NULL; - STRING *key = NULL; - STRING *sign = NULL; + ssh_string user = NULL; + ssh_string service = NULL; + ssh_string method = NULL; + ssh_string algo = NULL; + ssh_string key = NULL; + ssh_string sign = NULL; int rc = SSH_AUTH_ERROR; enter_function(); @@ -663,10 +663,10 @@ error: */ int ssh_userauth_password(SSH_SESSION *session, const char *username, const char *password) { - STRING *user = NULL; - STRING *service = NULL; - STRING *method = NULL; - STRING *pwd = NULL; + ssh_string user = NULL; + ssh_string service = NULL; + ssh_string method = NULL; + ssh_string pwd = NULL; int rc = SSH_AUTH_ERROR; enter_function(); @@ -796,7 +796,7 @@ static struct ssh_keys_struct keytab[] = { */ int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase) { struct ssh_public_key_struct *publickey; - STRING *pubkey; + ssh_string pubkey; PRIVATE_KEY *privkey; char *privkeyfile = NULL; char *id = NULL; @@ -1075,10 +1075,10 @@ static void kbdint_clean(struct ssh_kbdint *kbd) { * of the draft */ static int kbdauth_init(SSH_SESSION *session, const char *user, const char *submethods) { - STRING *usr = NULL; - STRING *sub = NULL; - STRING *service = NULL; - STRING *method = NULL; + ssh_string usr = NULL; + ssh_string sub = NULL; + ssh_string service = NULL; + ssh_string method = NULL; int rc = SSH_AUTH_ERROR; enter_function(); @@ -1134,9 +1134,9 @@ error: } static int kbdauth_info_get(SSH_SESSION *session) { - STRING *name; /* name of the "asking" window showed to client */ - STRING *instruction; - STRING *tmp; + ssh_string name; /* name of the "asking" window showed to client */ + ssh_string instruction; + ssh_string tmp; u32 nprompts; u32 i; @@ -1251,7 +1251,7 @@ static int kbdauth_info_get(SSH_SESSION *session) { /* sends challenge back to the server */ static int kbdauth_send(SSH_SESSION *session) { - STRING *answer = NULL; + ssh_string answer = NULL; int rc = SSH_AUTH_ERROR; u32 i; diff --git a/libssh/channels.c b/libssh/channels.c index 3b36299d..701fc445 100644 --- a/libssh/channels.c +++ b/libssh/channels.c @@ -109,7 +109,7 @@ u32 ssh_channel_new_id(SSH_SESSION *session) { static int channel_open(CHANNEL *channel, const char *type_c, int window, int maxpacket, BUFFER *payload) { SSH_SESSION *session = channel->session; - STRING *type = NULL; + ssh_string type = NULL; u32 tmp = 0; enter_function(); @@ -196,7 +196,7 @@ static int channel_open(CHANNEL *channel, const char *type_c, int window, return 0; case SSH2_MSG_CHANNEL_OPEN_FAILURE: { - STRING *error_s; + ssh_string error_s; char *error; u32 code; @@ -342,7 +342,7 @@ static void channel_rcv_change_window(SSH_SESSION *session) { /* is_stderr is set to 1 if the data are extended, ie stderr */ static void channel_rcv_data(SSH_SESSION *session,int is_stderr) { CHANNEL *channel; - STRING *str; + ssh_string str; size_t len; enter_function(); @@ -469,7 +469,7 @@ static void channel_rcv_close(SSH_SESSION *session) { static void channel_rcv_request(SSH_SESSION *session) { CHANNEL *channel; - STRING *request_s; + ssh_string request_s; char *request; u32 status; @@ -510,7 +510,7 @@ static void channel_rcv_request(SSH_SESSION *session) { if (strcmp(request, "exit-signal") == 0) { const char *core = "(core dumped)"; - STRING *signal_s; + ssh_string signal_s; char *signal; u8 i; @@ -674,7 +674,7 @@ int channel_open_forward(CHANNEL *channel, const char *remotehost, int remoteport, const char *sourcehost, int localport) { SSH_SESSION *session = channel->session; BUFFER *payload = NULL; - STRING *str = NULL; + ssh_string str = NULL; int rc = SSH_ERROR; enter_function(); @@ -1007,7 +1007,7 @@ void channel_set_blocking(CHANNEL *channel, int blocking) { static int channel_request(CHANNEL *channel, const char *request, BUFFER *buffer, int reply) { SSH_SESSION *session = channel->session; - STRING *req = NULL; + ssh_string req = NULL; int rc = SSH_ERROR; enter_function(); @@ -1085,7 +1085,7 @@ error: int channel_request_pty_size(CHANNEL *channel, const char *terminal, int col, int row) { SSH_SESSION *session = channel->session; - STRING *term = NULL; + ssh_string term = NULL; BUFFER *buffer = NULL; int rc = SSH_ERROR; @@ -1216,7 +1216,7 @@ int channel_request_shell(CHANNEL *channel) { */ int channel_request_subsystem(CHANNEL *channel, const char *sys) { BUFFER *buffer = NULL; - STRING *subsystem = NULL; + ssh_string subsystem = NULL; int rc = SSH_ERROR; buffer = buffer_new(); @@ -1260,7 +1260,7 @@ int channel_request_sftp( CHANNEL *channel){ * */ int channel_request_env(CHANNEL *channel, const char *name, const char *value) { BUFFER *buffer = NULL; - STRING *str = NULL; + ssh_string str = NULL; int rc = SSH_ERROR; buffer = buffer_new(); @@ -1311,7 +1311,7 @@ error: */ int channel_request_exec(CHANNEL *channel, const char *cmd) { BUFFER *buffer = NULL; - STRING *command = NULL; + ssh_string command = NULL; int rc = SSH_ERROR; #ifdef HAVE_SSH1 diff --git a/libssh/client.c b/libssh/client.c index 3f56a7b1..acccd146 100644 --- a/libssh/client.c +++ b/libssh/client.c @@ -190,10 +190,10 @@ int ssh_send_banner(SSH_SESSION *session, int server) { #define DH_STATE_NEWKEYS_SENT 4 #define DH_STATE_FINISHED 5 static int dh_handshake(SSH_SESSION *session) { - STRING *e = NULL; - STRING *f = NULL; - STRING *pubkey = NULL; - STRING *signature = NULL; + ssh_string e = NULL; + ssh_string f = NULL; + ssh_string pubkey = NULL; + ssh_string signature = NULL; int rc = SSH_ERROR; enter_function(); @@ -400,7 +400,7 @@ error: * @return 0 on success, < 0 on error. */ int ssh_service_request(SSH_SESSION *session, const char *service) { - STRING *service_s = NULL; + ssh_string service_s = NULL; enter_function(); @@ -621,7 +621,7 @@ char *ssh_get_issue_banner(SSH_SESSION *session) { * @param session The SSH session to disconnect. */ void ssh_disconnect(SSH_SESSION *session) { - STRING *str = NULL; + ssh_string str = NULL; if (session == NULL) { return; diff --git a/libssh/dh.c b/libssh/dh.c index d9262150..23e2d631 100644 --- a/libssh/dh.c +++ b/libssh/dh.c @@ -324,8 +324,8 @@ int dh_generate_f(SSH_SESSION *session) { return 0; } -STRING *make_bignum_string(bignum num) { - STRING *ptr = NULL; +ssh_string make_bignum_string(bignum num) { + ssh_string ptr = NULL; int pad = 0; unsigned int len = bignum_num_bytes(num); unsigned int bits = bignum_num_bits(num); @@ -358,7 +358,7 @@ STRING *make_bignum_string(bignum num) { return ptr; } -bignum make_string_bn(STRING *string){ +bignum make_string_bn(ssh_string string){ bignum bn = NULL; unsigned int len = string_len(string); @@ -376,20 +376,20 @@ bignum make_string_bn(STRING *string){ return bn; } -STRING *dh_get_e(SSH_SESSION *session) { +ssh_string dh_get_e(SSH_SESSION *session) { return make_bignum_string(session->next_crypto->e); } /* used by server */ -STRING *dh_get_f(SSH_SESSION *session) { +ssh_string dh_get_f(SSH_SESSION *session) { return make_bignum_string(session->next_crypto->f); } -void dh_import_pubkey(SSH_SESSION *session, STRING *pubkey_string) { +void dh_import_pubkey(SSH_SESSION *session, ssh_string pubkey_string) { session->next_crypto->server_pubkey = pubkey_string; } -int dh_import_f(SSH_SESSION *session, STRING *f_string) { +int dh_import_f(SSH_SESSION *session, ssh_string f_string) { session->next_crypto->f = make_string_bn(f_string); if (session->next_crypto->f == NULL) { return -1; @@ -403,7 +403,7 @@ int dh_import_f(SSH_SESSION *session, STRING *f_string) { } /* used by the server implementation */ -int dh_import_e(SSH_SESSION *session, STRING *e_string) { +int dh_import_e(SSH_SESSION *session, ssh_string e_string) { session->next_crypto->e = make_string_bn(e_string); if (session->next_crypto->e == NULL) { return -1; @@ -465,7 +465,7 @@ int dh_build_k(SSH_SESSION *session) { } /* -static void sha_add(STRING *str,SHACTX ctx){ +static void sha_add(ssh_string str,SHACTX ctx){ sha1_update(ctx,str,string_len(str)+4); #ifdef DEBUG_CRYPTO ssh_print_hexa("partial hashed sessionid",str,string_len(str)+4); @@ -475,8 +475,8 @@ static void sha_add(STRING *str,SHACTX ctx){ int make_sessionid(SSH_SESSION *session) { SHACTX ctx; - STRING *num = NULL; - STRING *str = NULL; + ssh_string num = NULL; + ssh_string str = NULL; BUFFER *server_hash = NULL; BUFFER *client_hash = NULL; BUFFER *buf = NULL; @@ -665,7 +665,7 @@ int hashbufin_add_cookie(SSH_SESSION *session, unsigned char *cookie) { return 0; } -static int generate_one_key(STRING *k, +static int generate_one_key(ssh_string k, unsigned char session_id[SHA_DIGEST_LEN], unsigned char output[SHA_DIGEST_LEN], char letter) { @@ -686,7 +686,7 @@ static int generate_one_key(STRING *k, } int generate_session_keys(SSH_SESSION *session) { - STRING *k_string = NULL; + ssh_string k_string = NULL; SHACTX ctx = NULL; int rc = -1; @@ -816,7 +816,7 @@ error: * @see ssh_print_hexa() */ int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash) { - STRING *pubkey; + ssh_string pubkey; MD5CTX ctx; unsigned char *h; @@ -847,7 +847,7 @@ int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash) { return MD5_DIGEST_LEN; } -STRING *ssh_get_pubkey(SSH_SESSION *session){ +ssh_string ssh_get_pubkey(SSH_SESSION *session){ return string_copy(session->current_crypto->server_pubkey); } @@ -970,7 +970,7 @@ static int sig_verify(SSH_SESSION *session, PUBLIC_KEY *pubkey, return -1; } -int signature_verify(SSH_SESSION *session, STRING *signature) { +int signature_verify(SSH_SESSION *session, ssh_string signature) { PUBLIC_KEY *pubkey = NULL; SIGNATURE *sign = NULL; int err; diff --git a/libssh/kex.c b/libssh/kex.c index fca16fbf..a9bfdefa 100644 --- a/libssh/kex.c +++ b/libssh/kex.c @@ -233,7 +233,7 @@ char *ssh_find_matching(const char *in_d, const char *what_d){ } int ssh_get_kex(SSH_SESSION *session, int server_kex) { - STRING *str = NULL; + ssh_string str = NULL; char *strings[10]; int i; @@ -373,7 +373,7 @@ int set_kex(SSH_SESSION *session){ /* this function only sends the predefined set of kex methods */ int ssh_send_kex(SSH_SESSION *session, int server_kex) { KEX *kex = (server_kex ? &session->server_kex : &session->client_kex); - STRING *str = NULL; + ssh_string str = NULL; int i; enter_function(); @@ -444,10 +444,10 @@ int verify_existing_algo(int algo, const char *name){ /* makes a STRING contating 3 strings : ssh-rsa1,e and n */ /* this is a public key in openssh's format */ -static STRING *make_rsa1_string(STRING *e, STRING *n){ +static ssh_string make_rsa1_string(ssh_string e, ssh_string n){ BUFFER *buffer = NULL; - STRING *rsa = NULL; - STRING *ret = NULL; + ssh_string rsa = NULL; + ssh_string ret = NULL; buffer = buffer_new(); rsa = string_from_char("ssh-rsa1"); @@ -475,8 +475,8 @@ error: return ret; } -static int build_session_id1(SSH_SESSION *session, STRING *servern, - STRING *hostn) { +static int build_session_id1(SSH_SESSION *session, ssh_string servern, + ssh_string hostn) { MD5CTX md5 = NULL; md5 = md5_init(); @@ -529,12 +529,12 @@ static int modulus_smaller(PUBLIC_KEY *k1, PUBLIC_KEY *k2){ } #define ABS(A) ( (A)<0 ? -(A):(A) ) -static STRING *encrypt_session_key(SSH_SESSION *session, PUBLIC_KEY *srvkey, +static ssh_string encrypt_session_key(SSH_SESSION *session, PUBLIC_KEY *srvkey, PUBLIC_KEY *hostkey, int slen, int hlen) { unsigned char buffer[32] = {0}; int i; - STRING *data1 = NULL; - STRING *data2 = NULL; + ssh_string data1 = NULL; + ssh_string data2 = NULL; /* first, generate a session key */ ssh_get_random(session->next_crypto->encryptkey, 32, 1); @@ -607,13 +607,13 @@ static STRING *encrypt_session_key(SSH_SESSION *session, PUBLIC_KEY *srvkey, */ int ssh_get_kex1(SSH_SESSION *session) { - STRING *server_exp = NULL; - STRING *server_mod = NULL; - STRING *host_exp = NULL; - STRING *host_mod = NULL; - STRING *serverkey = NULL; - STRING *hostkey = NULL; - STRING *enc_session = NULL; + ssh_string server_exp = NULL; + ssh_string server_mod = NULL; + ssh_string host_exp = NULL; + ssh_string host_mod = NULL; + ssh_string serverkey = NULL; + ssh_string hostkey = NULL; + ssh_string enc_session = NULL; PUBLIC_KEY *srv = NULL; PUBLIC_KEY *host = NULL; u32 server_bits; diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c index daed48bf..37d898d5 100644 --- a/libssh/keyfiles.c +++ b/libssh/keyfiles.c @@ -120,8 +120,8 @@ static u32 asn1_get_len(BUFFER *buffer) { return len; } -static STRING *asn1_get_int(BUFFER *buffer) { - STRING *str; +static ssh_string asn1_get_int(BUFFER *buffer) { + ssh_string str; unsigned char type; u32 size; @@ -443,15 +443,15 @@ static BUFFER *privatekey_file_to_buffer(FILE *fp, int type, static int read_rsa_privatekey(FILE *fp, gcry_sexp_t *r, ssh_auth_callback cb, void *userdata, const char *desc) { - STRING *n = NULL; - STRING *e = NULL; - STRING *d = NULL; - STRING *p = NULL; - STRING *q = NULL; - STRING *unused1 = NULL; - STRING *unused2 = NULL; - STRING *u = NULL; - STRING *v = NULL; + ssh_string n = NULL; + ssh_string e = NULL; + ssh_string d = NULL; + ssh_string p = NULL; + ssh_string q = NULL; + ssh_string unused1 = NULL; + ssh_string unused2 = NULL; + ssh_string u = NULL; + ssh_string v = NULL; BUFFER *buffer = NULL; int rc = 1; @@ -516,12 +516,12 @@ error: static int read_dsa_privatekey(FILE *fp, gcry_sexp_t *r, ssh_auth_callback cb, void *userdata, const char *desc) { BUFFER *buffer = NULL; - STRING *p = NULL; - STRING *q = NULL; - STRING *g = NULL; - STRING *y = NULL; - STRING *x = NULL; - STRING *v = NULL; + ssh_string p = NULL; + ssh_string q = NULL; + ssh_string g = NULL; + ssh_string y = NULL; + ssh_string x = NULL; + ssh_string v = NULL; int rc = 1; buffer = privatekey_file_to_buffer(fp, TYPE_DSS, cb, userdata, desc); @@ -853,11 +853,11 @@ void privatekey_free(PRIVATE_KEY *prv) { * \see string_free() * \see publickey_from_privatekey() */ -STRING *publickey_from_file(SSH_SESSION *session, const char *filename, +ssh_string publickey_from_file(SSH_SESSION *session, const char *filename, int *type) { BUFFER *buffer = NULL; char buf[4096] = {0}; - STRING *str = NULL; + ssh_string str = NULL; char *ptr = NULL; int key_type; int fd = -1; @@ -922,7 +922,7 @@ STRING *publickey_from_file(SSH_SESSION *session, const char *filename, return str; } -STRING *try_publickey_from_file(SSH_SESSION *session, struct ssh_keys_struct keytab, +ssh_string try_publickey_from_file(SSH_SESSION *session, struct ssh_keys_struct keytab, char **privkeyfile, int *type) { static char *home = NULL; @@ -931,7 +931,7 @@ STRING *try_publickey_from_file(SSH_SESSION *session, struct ssh_keys_struct key const char *priv; const char *pub; char *new; - STRING *pubkey; + ssh_string pubkey; if (home == NULL) { home = ssh_get_user_home_dir(); @@ -1137,7 +1137,7 @@ static char **ssh_get_knownhost_line(SSH_SESSION *session, FILE **file, * \return -1 on error */ static int check_public_key(SSH_SESSION *session, char **tokens) { - STRING *pubkey = session->current_crypto->server_pubkey; + ssh_string pubkey = session->current_crypto->server_pubkey; BUFFER *pubkey_buffer; char *pubkey_64; @@ -1145,7 +1145,7 @@ static int check_public_key(SSH_SESSION *session, char **tokens) { if (alldigits(tokens[1])) { /* openssh rsa1 format */ bignum tmpbn; - STRING *tmpstring; + ssh_string tmpstring; unsigned int len; int i; @@ -1442,7 +1442,7 @@ int ssh_is_server_known(SSH_SESSION *session) { * \return 0 on success, -1 on error */ int ssh_write_knownhost(SSH_SESSION *session) { - STRING *pubkey = session->current_crypto->server_pubkey; + ssh_string pubkey = session->current_crypto->server_pubkey; unsigned char *pubkey_64; char buffer[4096] = {0}; FILE *file; diff --git a/libssh/keys.c b/libssh/keys.c index 828a87d4..b8d9c9ce 100644 --- a/libssh/keys.c +++ b/libssh/keys.c @@ -66,10 +66,10 @@ int ssh_type_from_name(const char *name) { } PUBLIC_KEY *publickey_make_dss(SSH_SESSION *session, BUFFER *buffer) { - STRING *p = NULL; - STRING *q = NULL; - STRING *g = NULL; - STRING *pubkey = NULL; + ssh_string p = NULL; + ssh_string q = NULL; + ssh_string g = NULL; + ssh_string pubkey = NULL; PUBLIC_KEY *key = NULL; key = malloc(sizeof(PUBLIC_KEY)); @@ -153,8 +153,8 @@ error: PUBLIC_KEY *publickey_make_rsa(SSH_SESSION *session, BUFFER *buffer, int type) { - STRING *e = NULL; - STRING *n = NULL; + ssh_string e = NULL; + ssh_string n = NULL; PUBLIC_KEY *key = NULL; key = malloc(sizeof(PUBLIC_KEY)); @@ -245,9 +245,9 @@ void publickey_free(PUBLIC_KEY *key) { SAFE_FREE(key); } -PUBLIC_KEY *publickey_from_string(SSH_SESSION *session, STRING *pubkey_s) { +PUBLIC_KEY *publickey_from_string(SSH_SESSION *session, ssh_string pubkey_s) { BUFFER *tmpbuf = NULL; - STRING *type_s = NULL; + ssh_string type_s = NULL; char *type_c = NULL; int type; @@ -302,12 +302,12 @@ PUBLIC_KEY *publickey_from_privatekey(PRIVATE_KEY *prv) { gcry_sexp_t sexp; const char *tmp = NULL; size_t size; - STRING *p = NULL; - STRING *q = NULL; - STRING *g = NULL; - STRING *y = NULL; - STRING *e = NULL; - STRING *n = NULL; + ssh_string p = NULL; + ssh_string q = NULL; + ssh_string g = NULL; + ssh_string y = NULL; + ssh_string e = NULL; + ssh_string n = NULL; #endif /* HAVE_LIBGCRYPT */ key = malloc(sizeof(PUBLIC_KEY)); @@ -482,10 +482,10 @@ static int dsa_public_to_string(gcry_sexp_t key, BUFFER *buffer) { #elif defined HAVE_LIBCRYPTO static int dsa_public_to_string(DSA *key, BUFFER *buffer) { #endif - STRING *p = NULL; - STRING *q = NULL; - STRING *g = NULL; - STRING *n = NULL; + ssh_string p = NULL; + ssh_string q = NULL; + ssh_string g = NULL; + ssh_string n = NULL; int rc = -1; @@ -588,8 +588,8 @@ static int rsa_public_to_string(gcry_sexp_t key, BUFFER *buffer) { static int rsa_public_to_string(RSA *key, BUFFER *buffer) { #endif - STRING *e = NULL; - STRING *n = NULL; + ssh_string e = NULL; + ssh_string n = NULL; int rc = -1; @@ -655,9 +655,9 @@ error: * \returns a SSH String containing the public key * \see string_free() */ -STRING *publickey_to_string(PUBLIC_KEY *key) { - STRING *type = NULL; - STRING *ret = NULL; +ssh_string publickey_to_string(PUBLIC_KEY *key) { + ssh_string type = NULL; + ssh_string ret = NULL; BUFFER *buf = NULL; buf = buffer_new(); @@ -702,12 +702,12 @@ error: } /* Signature decoding functions */ -static STRING *signature_to_string(SIGNATURE *sign) { +static ssh_string signature_to_string(SIGNATURE *sign) { unsigned char buffer[40] = {0}; BUFFER *tmpbuf = NULL; - STRING *str = NULL; - STRING *tmp = NULL; - STRING *rs = NULL; + ssh_string str = NULL; + ssh_string tmp = NULL; + ssh_string rs = NULL; int rc = -1; #ifdef HAVE_LIBGCRYPT const char *r = NULL; @@ -715,8 +715,8 @@ static STRING *signature_to_string(SIGNATURE *sign) { gcry_sexp_t sexp; size_t size = 0; #elif defined HAVE_LIBCRYPTO - STRING *r = NULL; - STRING *s = NULL; + ssh_string r = NULL; + ssh_string s = NULL; #endif tmpbuf = buffer_new(); @@ -846,13 +846,13 @@ static STRING *signature_to_string(SIGNATURE *sign) { } /* TODO : split this function in two so it becomes smaller */ -SIGNATURE *signature_from_string(SSH_SESSION *session, STRING *signature, +SIGNATURE *signature_from_string(SSH_SESSION *session, ssh_string signature, PUBLIC_KEY *pubkey, int needed_type) { SIGNATURE *sign = NULL; BUFFER *tmpbuf = NULL; - STRING *rs = NULL; - STRING *type_s = NULL; - STRING *e = NULL; + ssh_string rs = NULL; + ssh_string type_s = NULL; + ssh_string e = NULL; char *type_c = NULL; int type; int len; @@ -861,8 +861,8 @@ SIGNATURE *signature_from_string(SSH_SESSION *session, STRING *signature, gcry_sexp_t sig; #elif defined HAVE_LIBCRYPTO DSA_SIG *sig = NULL; - STRING *r = NULL; - STRING *s = NULL; + ssh_string r = NULL; + ssh_string s = NULL; #endif sign = malloc(sizeof(SIGNATURE)); @@ -1070,8 +1070,8 @@ void signature_free(SIGNATURE *sign) { * I think now, maybe it's a bad idea to name it has it should have be * named in libcrypto */ -static STRING *RSA_do_sign(const unsigned char *payload, int len, RSA *privkey) { - STRING *sign = NULL; +static ssh_string RSA_do_sign(const unsigned char *payload, int len, RSA *privkey) { + ssh_string sign = NULL; unsigned char *buffer = NULL; unsigned int size; @@ -1099,7 +1099,7 @@ static STRING *RSA_do_sign(const unsigned char *payload, int len, RSA *privkey) #endif #ifndef _WIN32 -STRING *ssh_do_sign_with_agent(struct ssh_session *session, +ssh_string ssh_do_sign_with_agent(struct ssh_session *session, struct ssh_buffer_struct *buf, struct ssh_public_key_struct *publickey) { struct ssh_buffer_struct *sigbuf = NULL; struct ssh_string_struct *signature = NULL; @@ -1150,13 +1150,13 @@ STRING *ssh_do_sign_with_agent(struct ssh_session *session, /* * This function signs the session id (known as H) as a string then * the content of sigbuf */ -STRING *ssh_do_sign(SSH_SESSION *session, BUFFER *sigbuf, +ssh_string ssh_do_sign(SSH_SESSION *session, BUFFER *sigbuf, PRIVATE_KEY *privatekey) { CRYPTO *crypto = session->current_crypto ? session->current_crypto : session->next_crypto; unsigned char hash[SHA_DIGEST_LEN + 1] = {0}; - STRING *session_str = NULL; - STRING *signature = NULL; + ssh_string session_str = NULL; + ssh_string signature = NULL; SIGNATURE *sign = NULL; SHACTX ctx = NULL; #ifdef HAVE_LIBGCRYPT @@ -1249,8 +1249,8 @@ STRING *ssh_do_sign(SSH_SESSION *session, BUFFER *sigbuf, return signature; } -STRING *ssh_encrypt_rsa1(SSH_SESSION *session, STRING *data, PUBLIC_KEY *key) { - STRING *str = NULL; +ssh_string ssh_encrypt_rsa1(SSH_SESSION *session, ssh_string data, PUBLIC_KEY *key) { + ssh_string str = NULL; size_t len = string_len(data); size_t size = 0; #ifdef HAVE_LIBGCRYPT @@ -1315,11 +1315,11 @@ STRING *ssh_encrypt_rsa1(SSH_SESSION *session, STRING *data, PUBLIC_KEY *key) { /* this function signs the session id */ -STRING *ssh_sign_session_id(SSH_SESSION *session, PRIVATE_KEY *privatekey) { +ssh_string ssh_sign_session_id(SSH_SESSION *session, PRIVATE_KEY *privatekey) { CRYPTO *crypto=session->current_crypto ? session->current_crypto : session->next_crypto; unsigned char hash[SHA_DIGEST_LEN + 1] = {0}; - STRING *signature = NULL; + ssh_string signature = NULL; SIGNATURE *sign = NULL; SHACTX ctx = NULL; #ifdef HAVE_LIBGCRYPT diff --git a/libssh/messages.c b/libssh/messages.c index 8bcb918d..f562d8d7 100644 --- a/libssh/messages.c +++ b/libssh/messages.c @@ -57,7 +57,7 @@ static SSH_MESSAGE *message_new(SSH_SESSION *session){ } static SSH_MESSAGE *handle_service_request(SSH_SESSION *session) { - STRING *service = NULL; + ssh_string service = NULL; char *service_c = NULL; SSH_MESSAGE *msg=NULL; @@ -131,9 +131,9 @@ static int handle_unimplemented(SSH_SESSION *session) { } static SSH_MESSAGE *handle_userauth_request(SSH_SESSION *session){ - STRING *user = NULL; - STRING *service = NULL; - STRING *method = NULL; + ssh_string user = NULL; + ssh_string service = NULL; + ssh_string method = NULL; SSH_MESSAGE *msg = NULL; char *service_c = NULL; char *method_c = NULL; @@ -192,7 +192,7 @@ static SSH_MESSAGE *handle_userauth_request(SSH_SESSION *session){ } if (strcmp(method_c, "password") == 0) { - STRING *pass = NULL; + ssh_string pass = NULL; u8 tmp; msg->auth_request.method = SSH_AUTH_PASSWORD; @@ -259,7 +259,7 @@ int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods) { static int ssh_message_auth_reply_default(SSH_MESSAGE *msg,int partial) { SSH_SESSION *session = msg->session; char methods_c[128] = {0}; - STRING *methods = NULL; + ssh_string methods = NULL; int rc = SSH_ERROR; enter_function(); @@ -335,7 +335,7 @@ int ssh_message_auth_reply_success(SSH_MESSAGE *msg, int partial) { static SSH_MESSAGE *handle_channel_request_open(SSH_SESSION *session) { SSH_MESSAGE *msg = NULL; - STRING *type = NULL; + ssh_string type = NULL; char *type_c = NULL; u32 sender, window, packet; @@ -479,7 +479,7 @@ error: static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session) { SSH_MESSAGE *msg = NULL; - STRING *type = NULL; + ssh_string type = NULL; char *type_c = NULL; u32 channel; u8 want_reply; @@ -515,7 +515,7 @@ static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session) { msg->channel_request.want_reply = want_reply; if (strcmp(type_c, "pty-req") == 0) { - STRING *term = NULL; + ssh_string term = NULL; char *term_c = NULL; SAFE_FREE(type_c); @@ -553,7 +553,7 @@ static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session) { } if (strcmp(type_c, "subsystem") == 0) { - STRING *subsys = NULL; + ssh_string subsys = NULL; char *subsys_c = NULL; SAFE_FREE(type_c); @@ -584,7 +584,7 @@ static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session) { return msg; } if (strcmp(type_c, "exec") == 0) { - STRING *cmd = NULL; + ssh_string cmd = NULL; SAFE_FREE(type_c); diff --git a/libssh/packet.c b/libssh/packet.c index 2304441c..f3742e4e 100644 --- a/libssh/packet.c +++ b/libssh/packet.c @@ -592,7 +592,7 @@ int packet_send(SSH_SESSION *session) { } void packet_parse(SSH_SESSION *session) { - STRING *error_s = NULL; + ssh_string error_s = NULL; char *error = NULL; u32 type = session->in_packet.type; u32 tmp; diff --git a/libssh/server.c b/libssh/server.c index 25021f68..7b33cc6d 100644 --- a/libssh/server.c +++ b/libssh/server.c @@ -325,10 +325,10 @@ static int server_set_kex(SSH_SESSION * session) { } static int dh_handshake_server(SSH_SESSION *session) { - STRING *e; - STRING *f; - STRING *pubkey; - STRING *sign; + ssh_string e; + ssh_string f; + ssh_string pubkey; + ssh_string sign; PUBLIC_KEY *pub; PRIVATE_KEY *prv; diff --git a/libssh/sftp.c b/libssh/sftp.c index 790984aa..ab361043 100644 --- a/libssh/sftp.c +++ b/libssh/sftp.c @@ -419,8 +419,8 @@ void sftp_packet_free(SFTP_PACKET *packet) { int sftp_init(SFTP_SESSION *sftp) { SFTP_PACKET *packet = NULL; BUFFER *buffer = NULL; - STRING *ext_name_s = NULL; - STRING *ext_data_s = NULL; + ssh_string ext_name_s = NULL; + ssh_string ext_data_s = NULL; char *ext_name = NULL; char *ext_data = NULL; u32 version = htonl(LIBSFTP_VERSION); @@ -672,7 +672,7 @@ SFTP_DIR *sftp_opendir(SFTP_SESSION *sftp, const char *path){ SFTP_FILE *file = NULL; SFTP_DIR *dir = NULL; STATUS_MESSAGE *status; - STRING *path_s; + ssh_string path_s; BUFFER *payload; u32 id; @@ -760,8 +760,8 @@ SFTP_DIR *sftp_opendir(SFTP_SESSION *sftp, const char *path){ static SFTP_ATTRIBUTES *sftp_parse_attr_4(SFTP_SESSION *sftp, BUFFER *buf, int expectnames) { SFTP_ATTRIBUTES *attr; - STRING *owner = NULL; - STRING *group = NULL; + ssh_string owner = NULL; + ssh_string group = NULL; u32 flags = 0; int ok = 0; @@ -935,8 +935,8 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_4(SFTP_SESSION *sftp, BUFFER *buf, so that number of pairs equals extended_count */ static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, BUFFER *buf, int expectname) { - STRING *longname = NULL; - STRING *name = NULL; + ssh_string longname = NULL; + ssh_string name = NULL; SFTP_ATTRIBUTES *attr; u32 flags = 0; int ok = 0; @@ -1263,7 +1263,7 @@ void sftp_attributes_free(SFTP_ATTRIBUTES *file){ SAFE_FREE(file); } -static int sftp_handle_close(SFTP_SESSION *sftp, STRING *handle) { +static int sftp_handle_close(SFTP_SESSION *sftp, ssh_string handle) { STATUS_MESSAGE *status; SFTP_MESSAGE *msg = NULL; BUFFER *buffer = NULL; @@ -1366,7 +1366,7 @@ SFTP_FILE *sftp_open(SFTP_SESSION *sftp, const char *file, int flags, STATUS_MESSAGE *status; SFTP_ATTRIBUTES attr; SFTP_FILE *handle; - STRING *filename; + ssh_string filename; BUFFER *buffer; u32 sftp_flags = 0; u32 id; @@ -1463,7 +1463,7 @@ ssize_t sftp_read(SFTP_FILE *handle, void *buf, size_t count) { SFTP_SESSION *sftp = handle->sftp; SFTP_MESSAGE *msg = NULL; STATUS_MESSAGE *status; - STRING *datastring; + ssh_string datastring; BUFFER *buffer; int id; @@ -1587,7 +1587,7 @@ int sftp_async_read(SFTP_FILE *file, void *data, u32 size, u32 id){ SFTP_SESSION *sftp = file->sftp; SFTP_MESSAGE *msg = NULL; STATUS_MESSAGE *status; - STRING *datastring; + ssh_string datastring; int err = SSH_OK; u32 len; @@ -1677,7 +1677,7 @@ ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count) { SFTP_SESSION *sftp = file->sftp; SFTP_MESSAGE *msg = NULL; STATUS_MESSAGE *status; - STRING *datastring; + ssh_string datastring; BUFFER *buffer; u32 id; int len; @@ -1794,7 +1794,7 @@ int sftp_rm(SFTP_SESSION *sftp, const char *file) { int sftp_unlink(SFTP_SESSION *sftp, const char *file) { STATUS_MESSAGE *status = NULL; SFTP_MESSAGE *msg = NULL; - STRING *filename; + ssh_string filename; BUFFER *buffer; u32 id; @@ -1863,7 +1863,7 @@ int sftp_unlink(SFTP_SESSION *sftp, const char *file) { int sftp_rmdir(SFTP_SESSION *sftp, const char *directory) { STATUS_MESSAGE *status = NULL; SFTP_MESSAGE *msg = NULL; - STRING *filename; + ssh_string filename; BUFFER *buffer; u32 id; @@ -1933,7 +1933,7 @@ int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, mode_t mode) { SFTP_ATTRIBUTES *errno_attr = NULL; SFTP_ATTRIBUTES attr; BUFFER *buffer; - STRING *path; + ssh_string path; u32 id; buffer = buffer_new(); @@ -2020,8 +2020,8 @@ int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname) { STATUS_MESSAGE *status = NULL; SFTP_MESSAGE *msg = NULL; BUFFER *buffer; - STRING *oldpath; - STRING *newpath; + ssh_string oldpath; + ssh_string newpath; u32 id; buffer = buffer_new(); @@ -2103,7 +2103,7 @@ int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname) { int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr) { u32 id = sftp_get_new_id(sftp); BUFFER *buffer = buffer_new(); - STRING *path = string_from_char(file); + ssh_string path = string_from_char(file); SFTP_MESSAGE *msg = NULL; STATUS_MESSAGE *status = NULL; @@ -2216,8 +2216,8 @@ int sftp_utimes(SFTP_SESSION *sftp, const char *file, char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path) { STATUS_MESSAGE *status = NULL; SFTP_MESSAGE *msg = NULL; - STRING *name = NULL; - STRING *pathstr; + ssh_string name = NULL; + ssh_string pathstr; BUFFER *buffer; char *cname; u32 ignored; @@ -2291,7 +2291,7 @@ static SFTP_ATTRIBUTES *sftp_xstat(SFTP_SESSION *sftp, const char *path, int param) { STATUS_MESSAGE *status = NULL; SFTP_MESSAGE *msg = NULL; - STRING *pathstr; + ssh_string pathstr; BUFFER *buffer; u32 id; diff --git a/libssh/sftpserver.c b/libssh/sftpserver.c index b005799f..f5906a36 100644 --- a/libssh/sftpserver.c +++ b/libssh/sftpserver.c @@ -39,7 +39,7 @@ SFTP_CLIENT_MESSAGE *sftp_get_client_message(SFTP_SESSION *sftp) { SFTP_PACKET *packet; SFTP_CLIENT_MESSAGE *msg; BUFFER *payload; - STRING *tmp; + ssh_string tmp; msg = malloc(sizeof (SFTP_CLIENT_MESSAGE)); if (msg == NULL) { @@ -229,7 +229,7 @@ void sftp_client_message_free(SFTP_CLIENT_MESSAGE *msg) { int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name, SFTP_ATTRIBUTES *attr) { BUFFER *out; - STRING *file; + ssh_string file; out = buffer_new(); if (out == NULL) { @@ -258,7 +258,7 @@ int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name, return 0; } -int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, STRING *handle){ +int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, ssh_string handle){ BUFFER *out; out = buffer_new(); @@ -298,7 +298,7 @@ int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr) { int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, const char *file, const char *longname, SFTP_ATTRIBUTES *attr) { - STRING *name; + ssh_string name; name = string_from_char(file); if (name == NULL) { @@ -365,7 +365,7 @@ int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg) { int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, u32 status, const char *message) { BUFFER *out; - STRING *s; + ssh_string s; out = buffer_new(); if (out == NULL) { @@ -420,8 +420,8 @@ int sftp_reply_data(SFTP_CLIENT_MESSAGE *msg, const void *data, int len) { * the handle. Care is given that a corrupted handle won't give a * valid info (or worse). */ -STRING *sftp_handle_alloc(SFTP_SESSION *sftp, void *info) { - STRING *ret; +ssh_string sftp_handle_alloc(SFTP_SESSION *sftp, void *info) { + ssh_string ret; u32 val; int i; @@ -455,7 +455,7 @@ STRING *sftp_handle_alloc(SFTP_SESSION *sftp, void *info) { return ret; } -void *sftp_handle(SFTP_SESSION *sftp, STRING *handle){ +void *sftp_handle(SFTP_SESSION *sftp, ssh_string handle){ u32 val; if (sftp->handles == NULL) { |