X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=client_common.c;h=396fd88c894cda20e4f55a7955a9a4fe77e9633d;hb=refs%2Fheads%2Fpu;hp=e67a938b4df8aa69c2536505ce86c5017ab469b2;hpb=53293c816d0f0e0c2be8bd28920dc185829b0c2e;p=paraslash.git diff --git a/client_common.c b/client_common.c index e67a938b..cbd78bbb 100644 --- a/client_common.c +++ b/client_common.c @@ -324,7 +324,7 @@ static int client_post_monitor(struct sched *s, void *context) */ { /* decrypted challenge/session key buffer */ - unsigned char crypt_buf[1024]; + unsigned char *crypt_buf; struct sb_buffer sbb; ret = recv_sb(ct, &sbb); @@ -337,11 +337,16 @@ static int client_post_monitor(struct sched *s, void *context) } n = sbb.iov.iov_len; PARA_INFO_LOG("<-- [challenge] (%zu bytes)\n", n); - ret = apc_priv_decrypt(ct->key_file, crypt_buf, + ret = apc_priv_decrypt(ct->key_file, &crypt_buf, sbb.iov.iov_base, n); free(sbb.iov.iov_base); if (ret < 0) goto out; + if (ret != APC_CHALLENGE_SIZE + 2 * SESSION_KEY_LEN) { + free(crypt_buf); + ret = -E_DECRYPT; + goto out; + } ct->challenge_hash = alloc(HASH2_SIZE); if (has_feature("sha256", ct)) { hash2_function((char *)crypt_buf, APC_CHALLENGE_SIZE, @@ -356,6 +361,7 @@ static int client_post_monitor(struct sched *s, void *context) SESSION_KEY_LEN); ct->scc.recv = sc_new(crypt_buf + APC_CHALLENGE_SIZE + SESSION_KEY_LEN, SESSION_KEY_LEN); + free(crypt_buf); PARA_INFO_LOG("--> %s\n", buf); ct->status = CL_RECEIVED_CHALLENGE; return 0; @@ -585,8 +591,10 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr, const char *confdir = get_confdir(); kf = make_message("%s/key.%s", confdir, user); if (stat(kf, &statbuf) != 0) { /* assume file does not exist */ + const char *home = getenv("HOME"); + assert(home); /* get_confdir() above succeeded */ free(kf); - kf = make_message("%s/.ssh/id_rsa", confdir); + kf = make_message("%s/.ssh/id_rsa", home); } } PARA_INFO_LOG("user: %s\n", user);