summaryrefslogtreecommitdiff
path: root/monitor_wrap.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor_wrap.c')
-rw-r--r--monitor_wrap.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/monitor_wrap.c b/monitor_wrap.c
index e62650342..9662a4c63 100644
--- a/monitor_wrap.c
+++ b/monitor_wrap.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor_wrap.c,v 1.75 2013/01/08 18:49:04 markus Exp $ */ 1/* $OpenBSD: monitor_wrap.c,v 1.76 2013/05/17 00:13:13 djm Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * Copyright 2002 Markus Friedl <markus@openbsd.org> 4 * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -259,8 +259,10 @@ mm_getpwnamallow(const char *username)
259 fatal("%s: struct passwd size mismatch", __func__); 259 fatal("%s: struct passwd size mismatch", __func__);
260 pw->pw_name = buffer_get_string(&m, NULL); 260 pw->pw_name = buffer_get_string(&m, NULL);
261 pw->pw_passwd = buffer_get_string(&m, NULL); 261 pw->pw_passwd = buffer_get_string(&m, NULL);
262#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
262 pw->pw_gecos = buffer_get_string(&m, NULL); 263 pw->pw_gecos = buffer_get_string(&m, NULL);
263#ifdef HAVE_PW_CLASS_IN_PASSWD 264#endif
265#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
264 pw->pw_class = buffer_get_string(&m, NULL); 266 pw->pw_class = buffer_get_string(&m, NULL);
265#endif 267#endif
266 pw->pw_dir = buffer_get_string(&m, NULL); 268 pw->pw_dir = buffer_get_string(&m, NULL);
@@ -286,7 +288,7 @@ out:
286#undef M_CP_STRARRAYOPT 288#undef M_CP_STRARRAYOPT
287 289
288 copy_set_server_options(&options, newopts, 1); 290 copy_set_server_options(&options, newopts, 1);
289 xfree(newopts); 291 free(newopts);
290 292
291 buffer_free(&m); 293 buffer_free(&m);
292 294
@@ -312,7 +314,7 @@ mm_auth2_read_banner(void)
312 314
313 /* treat empty banner as missing banner */ 315 /* treat empty banner as missing banner */
314 if (strlen(banner) == 0) { 316 if (strlen(banner) == 0) {
315 xfree(banner); 317 free(banner);
316 banner = NULL; 318 banner = NULL;
317 } 319 }
318 return (banner); 320 return (banner);
@@ -423,7 +425,7 @@ mm_key_allowed(enum mm_keytype type, char *user, char *host, Key *key)
423 buffer_put_cstring(&m, user ? user : ""); 425 buffer_put_cstring(&m, user ? user : "");
424 buffer_put_cstring(&m, host ? host : ""); 426 buffer_put_cstring(&m, host ? host : "");
425 buffer_put_string(&m, blob, len); 427 buffer_put_string(&m, blob, len);
426 xfree(blob); 428 free(blob);
427 429
428 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYALLOWED, &m); 430 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYALLOWED, &m);
429 431
@@ -466,7 +468,7 @@ mm_key_verify(Key *key, u_char *sig, u_int siglen, u_char *data, u_int datalen)
466 buffer_put_string(&m, blob, len); 468 buffer_put_string(&m, blob, len);
467 buffer_put_string(&m, sig, siglen); 469 buffer_put_string(&m, sig, siglen);
468 buffer_put_string(&m, data, datalen); 470 buffer_put_string(&m, data, datalen);
469 xfree(blob); 471 free(blob);
470 472
471 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYVERIFY, &m); 473 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYVERIFY, &m);
472 474
@@ -635,7 +637,7 @@ mm_send_keystate(struct monitor *monitor)
635 keylen = packet_get_encryption_key(key); 637 keylen = packet_get_encryption_key(key);
636 buffer_put_string(&m, key, keylen); 638 buffer_put_string(&m, key, keylen);
637 memset(key, 0, keylen); 639 memset(key, 0, keylen);
638 xfree(key); 640 free(key);
639 641
640 ivlen = packet_get_keyiv_len(MODE_OUT); 642 ivlen = packet_get_keyiv_len(MODE_OUT);
641 packet_get_keyiv(MODE_OUT, iv, ivlen); 643 packet_get_keyiv(MODE_OUT, iv, ivlen);
@@ -658,13 +660,13 @@ mm_send_keystate(struct monitor *monitor)
658 fatal("%s: conversion of newkeys failed", __func__); 660 fatal("%s: conversion of newkeys failed", __func__);
659 661
660 buffer_put_string(&m, blob, bloblen); 662 buffer_put_string(&m, blob, bloblen);
661 xfree(blob); 663 free(blob);
662 664
663 if (!mm_newkeys_to_blob(MODE_IN, &blob, &bloblen)) 665 if (!mm_newkeys_to_blob(MODE_IN, &blob, &bloblen))
664 fatal("%s: conversion of newkeys failed", __func__); 666 fatal("%s: conversion of newkeys failed", __func__);
665 667
666 buffer_put_string(&m, blob, bloblen); 668 buffer_put_string(&m, blob, bloblen);
667 xfree(blob); 669 free(blob);
668 670
669 packet_get_state(MODE_OUT, &seqnr, &blocks, &packets, &bytes); 671 packet_get_state(MODE_OUT, &seqnr, &blocks, &packets, &bytes);
670 buffer_put_int(&m, seqnr); 672 buffer_put_int(&m, seqnr);
@@ -684,13 +686,13 @@ mm_send_keystate(struct monitor *monitor)
684 p = xmalloc(plen+1); 686 p = xmalloc(plen+1);
685 packet_get_keycontext(MODE_OUT, p); 687 packet_get_keycontext(MODE_OUT, p);
686 buffer_put_string(&m, p, plen); 688 buffer_put_string(&m, p, plen);
687 xfree(p); 689 free(p);
688 690
689 plen = packet_get_keycontext(MODE_IN, NULL); 691 plen = packet_get_keycontext(MODE_IN, NULL);
690 p = xmalloc(plen+1); 692 p = xmalloc(plen+1);
691 packet_get_keycontext(MODE_IN, p); 693 packet_get_keycontext(MODE_IN, p);
692 buffer_put_string(&m, p, plen); 694 buffer_put_string(&m, p, plen);
693 xfree(p); 695 free(p);
694 696
695 /* Compression state */ 697 /* Compression state */
696 debug3("%s: Sending compression state", __func__); 698 debug3("%s: Sending compression state", __func__);
@@ -752,10 +754,10 @@ mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
752 buffer_free(&m); 754 buffer_free(&m);
753 755
754 strlcpy(namebuf, p, namebuflen); /* Possible truncation */ 756 strlcpy(namebuf, p, namebuflen); /* Possible truncation */
755 xfree(p); 757 free(p);
756 758
757 buffer_append(&loginmsg, msg, strlen(msg)); 759 buffer_append(&loginmsg, msg, strlen(msg));
758 xfree(msg); 760 free(msg);
759 761
760 if ((*ptyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1 || 762 if ((*ptyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1 ||
761 (*ttyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1) 763 (*ttyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1)
@@ -821,7 +823,7 @@ mm_do_pam_account(void)
821 ret = buffer_get_int(&m); 823 ret = buffer_get_int(&m);
822 msg = buffer_get_string(&m, NULL); 824 msg = buffer_get_string(&m, NULL);
823 buffer_append(&loginmsg, msg, strlen(msg)); 825 buffer_append(&loginmsg, msg, strlen(msg));
824 xfree(msg); 826 free(msg);
825 827
826 buffer_free(&m); 828 buffer_free(&m);
827 829
@@ -1051,7 +1053,7 @@ mm_skey_query(void *ctx, char **name, char **infotxt,
1051 mm_chall_setup(name, infotxt, numprompts, prompts, echo_on); 1053 mm_chall_setup(name, infotxt, numprompts, prompts, echo_on);
1052 1054
1053 xasprintf(*prompts, "%s%s", challenge, SKEY_PROMPT); 1055 xasprintf(*prompts, "%s%s", challenge, SKEY_PROMPT);
1054 xfree(challenge); 1056 free(challenge);
1055 1057
1056 return (0); 1058 return (0);
1057} 1059}
@@ -1125,7 +1127,7 @@ mm_auth_rsa_key_allowed(struct passwd *pw, BIGNUM *client_n, Key **rkey)
1125 if ((key = key_from_blob(blob, blen)) == NULL) 1127 if ((key = key_from_blob(blob, blen)) == NULL)
1126 fatal("%s: key_from_blob failed", __func__); 1128 fatal("%s: key_from_blob failed", __func__);
1127 *rkey = key; 1129 *rkey = key;
1128 xfree(blob); 1130 free(blob);
1129 } 1131 }
1130 buffer_free(&m); 1132 buffer_free(&m);
1131 1133
@@ -1152,7 +1154,7 @@ mm_auth_rsa_generate_challenge(Key *key)
1152 1154
1153 buffer_init(&m); 1155 buffer_init(&m);
1154 buffer_put_string(&m, blob, blen); 1156 buffer_put_string(&m, blob, blen);
1155 xfree(blob); 1157 free(blob);
1156 1158
1157 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_RSACHALLENGE, &m); 1159 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_RSACHALLENGE, &m);
1158 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_RSACHALLENGE, &m); 1160 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_RSACHALLENGE, &m);
@@ -1181,7 +1183,7 @@ mm_auth_rsa_verify_response(Key *key, BIGNUM *p, u_char response[16])
1181 buffer_init(&m); 1183 buffer_init(&m);
1182 buffer_put_string(&m, blob, blen); 1184 buffer_put_string(&m, blob, blen);
1183 buffer_put_string(&m, response, 16); 1185 buffer_put_string(&m, response, 16);
1184 xfree(blob); 1186 free(blob);
1185 1187
1186 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_RSARESPONSE, &m); 1188 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_RSARESPONSE, &m);
1187 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_RSARESPONSE, &m); 1189 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_RSARESPONSE, &m);
@@ -1539,7 +1541,7 @@ mm_consolekit_register(Session *s, const char *display)
1539 1541
1540 /* treat empty cookie as missing cookie */ 1542 /* treat empty cookie as missing cookie */
1541 if (strlen(cookie) == 0) { 1543 if (strlen(cookie) == 0) {
1542 xfree(cookie); 1544 free(cookie);
1543 cookie = NULL; 1545 cookie = NULL;
1544 } 1546 }
1545 return (cookie); 1547 return (cookie);