=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/monitor_wrap.c,v retrieving revision 1.7.2.3 retrieving revision 1.8 diff -u -r1.7.2.3 -r1.8 --- src/usr.bin/ssh/monitor_wrap.c 2002/10/11 14:53:06 1.7.2.3 +++ src/usr.bin/ssh/monitor_wrap.c 2002/06/04 23:05:49 1.8 @@ -25,7 +25,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: monitor_wrap.c,v 1.7.2.3 2002/10/11 14:53:06 miod Exp $"); +RCSID("$OpenBSD: monitor_wrap.c,v 1.8 2002/06/04 23:05:49 markus Exp $"); #include #include @@ -62,13 +62,13 @@ void mm_request_send(int socket, enum monitor_reqtype type, Buffer *m) { - u_int mlen = buffer_len(m); u_char buf[5]; + u_int mlen = buffer_len(m); debug3("%s entering: type %d", __func__, type); PUT_32BIT(buf, mlen + 1); - buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ + buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ if (atomicio(write, socket, buf, sizeof(buf)) != sizeof(buf)) fatal("%s: write", __func__); if (atomicio(write, socket, buffer_ptr(m), mlen) != mlen) @@ -79,8 +79,8 @@ mm_request_receive(int socket, Buffer *m) { u_char buf[4]; - u_int msg_len; ssize_t res; + u_int msg_len; debug3("%s entering", __func__); @@ -205,7 +205,7 @@ return (pw); } -char *mm_auth2_read_banner(void) +char* mm_auth2_read_banner(void) { Buffer m; char *banner; @@ -219,7 +219,7 @@ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUTH2_READ_BANNER, &m); banner = buffer_get_string(&m, NULL); buffer_free(&m); - + return (banner); } @@ -409,7 +409,7 @@ enc->key = buffer_get_string(&b, &enc->key_len); enc->iv = buffer_get_string(&b, &len); if (len != enc->block_size) - fatal("%s: bad ivlen: expected %u != %u", __func__, + fatal("%s: bad ivlen: expected %d != %d", __func__, enc->block_size, len); if (enc->name == NULL || cipher_by_name(enc->name) != enc->cipher) @@ -423,7 +423,7 @@ mac->enabled = buffer_get_int(&b); mac->key = buffer_get_string(&b, &len); if (len > mac->key_len) - fatal("%s: bad mac key length: %u > %d", __func__, len, + fatal("%s: bad mac key lenght: %d > %d", __func__, len, mac->key_len); mac->key_len = len; @@ -434,7 +434,7 @@ len = buffer_len(&b); if (len != 0) - error("newkeys_from_blob: remaining bytes in blob %u", len); + error("newkeys_from_blob: remaining bytes in blob %d", len); buffer_free(&b); return (newkey); } @@ -444,6 +444,7 @@ { Buffer b; int len; + u_char *buf; Enc *enc; Mac *mac; Comp *comp; @@ -481,14 +482,14 @@ buffer_put_cstring(&b, comp->name); len = buffer_len(&b); - if (lenp != NULL) - *lenp = len; - if (blobp != NULL) { - *blobp = xmalloc(len); - memcpy(*blobp, buffer_ptr(&b), len); - } + buf = xmalloc(len); + memcpy(buf, buffer_ptr(&b), len); memset(buffer_ptr(&b), 0, len); buffer_free(&b); + if (lenp != NULL) + *lenp = len; + if (blobp != NULL) + *blobp = buf; return len; } @@ -517,21 +518,13 @@ if (!compat20) { u_char iv[24]; - u_char *key; - u_int ivlen, keylen; + int ivlen; buffer_put_int(&m, packet_get_protocol_flags()); buffer_put_int(&m, packet_get_ssh1_cipher()); - debug3("%s: Sending ssh1 KEY+IV", __func__); - keylen = packet_get_encryption_key(NULL); - key = xmalloc(keylen+1); /* add 1 if keylen == 0 */ - keylen = packet_get_encryption_key(key); - buffer_put_string(&m, key, keylen); - memset(key, 0, keylen); - xfree(key); - + debug3("%s: Sending ssh1 IV", __func__); ivlen = packet_get_keyiv_len(MODE_OUT); packet_get_keyiv(MODE_OUT, iv, ivlen); buffer_put_string(&m, iv, ivlen); @@ -597,7 +590,7 @@ mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) { Buffer m; - char *p; + u_char *p; int success = 0; buffer_init(&m); @@ -682,10 +675,10 @@ mm_chall_setup(char **name, char **infotxt, u_int *numprompts, char ***prompts, u_int **echo_on) { - *name = xstrdup(""); - *infotxt = xstrdup(""); + *name = xstrdup(""); + *infotxt = xstrdup(""); *numprompts = 1; - *prompts = xmalloc(*numprompts * sizeof(char *)); + *prompts = xmalloc(*numprompts * sizeof(char*)); *echo_on = xmalloc(*numprompts * sizeof(u_int)); (*echo_on)[0] = 0; } @@ -917,74 +910,3 @@ return (success); } - -#ifdef KRB4 -int -mm_auth_krb4(Authctxt *authctxt, void *_auth, char **client, void *_reply) -{ - KTEXT auth, reply; - Buffer m; - u_int rlen; - int success = 0; - char *p; - - debug3("%s entering", __func__); - auth = _auth; - reply = _reply; - - buffer_init(&m); - buffer_put_string(&m, auth->dat, auth->length); - - mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KRB4, &m); - mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KRB4, &m); - - success = buffer_get_int(&m); - if (success) { - *client = buffer_get_string(&m, NULL); - p = buffer_get_string(&m, &rlen); - if (rlen >= MAX_KTXT_LEN) - fatal("%s: reply from monitor too large", __func__); - reply->length = rlen; - memcpy(reply->dat, p, rlen); - memset(p, 0, rlen); - xfree(p); - } - buffer_free(&m); - return (success); -} -#endif - -#ifdef KRB5 -int -mm_auth_krb5(void *ctx, void *argp, char **userp, void *resp) -{ - krb5_data *tkt, *reply; - Buffer m; - int success; - - debug3("%s entering", __func__); - tkt = (krb5_data *) argp; - reply = (krb5_data *) resp; - - buffer_init(&m); - buffer_put_string(&m, tkt->data, tkt->length); - - mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KRB5, &m); - mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KRB5, &m); - - success = buffer_get_int(&m); - if (success) { - u_int len; - - *userp = buffer_get_string(&m, NULL); - reply->data = buffer_get_string(&m, &len); - reply->length = len; - } else { - memset(reply, 0, sizeof(*reply)); - *userp = NULL; - } - - buffer_free(&m); - return (success); -} -#endif