Bugzilla – Attachment 501 Details for
Bug 632
PAM conversation function does not return when connection is aborted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Don't fatal on msg functions
sshmsgcheck.diff (text/plain), 6.04 KB, created by
Damien Miller
on 2003-11-16 16:32:29 AEDT
(
hide
)
Description:
Don't fatal on msg functions
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2003-11-16 16:32:29 AEDT
Size:
6.04 KB
patch
obsolete
>Index: auth-pam.c >=================================================================== >RCS file: /var/cvs/openssh/auth-pam.c,v >retrieving revision 1.78 >diff -u -r1.78 auth-pam.c >--- auth-pam.c 13 Nov 2003 08:52:31 -0000 1.78 >+++ auth-pam.c 16 Nov 2003 23:18:13 -0000 >@@ -156,9 +156,11 @@ > case PAM_PROMPT_ECHO_OFF: > buffer_put_cstring(&buffer, > PAM_MSG_MEMBER(msg, i, msg)); >- ssh_msg_send(ctxt->pam_csock, >- PAM_MSG_MEMBER(msg, i, msg_style), &buffer); >- ssh_msg_recv(ctxt->pam_csock, &buffer); >+ if (ssh_msg_send(ctxt->pam_csock, >+ PAM_MSG_MEMBER(msg, i, msg_style), &buffer) == -1) >+ goto fail; >+ if (ssh_msg_recv(ctxt->pam_csock, &buffer) == -1) >+ goto fail; > if (buffer_get_char(&buffer) != PAM_AUTHTOK) > goto fail; > reply[i].resp = buffer_get_string(&buffer, NULL); >@@ -166,9 +168,11 @@ > case PAM_PROMPT_ECHO_ON: > buffer_put_cstring(&buffer, > PAM_MSG_MEMBER(msg, i, msg)); >- ssh_msg_send(ctxt->pam_csock, >- PAM_MSG_MEMBER(msg, i, msg_style), &buffer); >- ssh_msg_recv(ctxt->pam_csock, &buffer); >+ if (ssh_msg_send(ctxt->pam_csock, >+ PAM_MSG_MEMBER(msg, i, msg_style), &buffer) == -1) >+ goto fail; >+ if (ssh_msg_recv(ctxt->pam_csock, &buffer) == -1) >+ goto fail; > if (buffer_get_char(&buffer) != PAM_AUTHTOK) > goto fail; > reply[i].resp = buffer_get_string(&buffer, NULL); >@@ -176,14 +180,16 @@ > case PAM_ERROR_MSG: > buffer_put_cstring(&buffer, > PAM_MSG_MEMBER(msg, i, msg)); >- ssh_msg_send(ctxt->pam_csock, >- PAM_MSG_MEMBER(msg, i, msg_style), &buffer); >+ if (ssh_msg_send(ctxt->pam_csock, >+ PAM_MSG_MEMBER(msg, i, msg_style), &buffer) == -1) >+ goto fail; > break; > case PAM_TEXT_INFO: > buffer_put_cstring(&buffer, > PAM_MSG_MEMBER(msg, i, msg)); >- ssh_msg_send(ctxt->pam_csock, >- PAM_MSG_MEMBER(msg, i, msg_style), &buffer); >+ if (ssh_msg_send(ctxt->pam_csock, >+ PAM_MSG_MEMBER(msg, i, msg_style), &buffer) == -1) >+ goto fail; > break; > default: > goto fail; >@@ -232,6 +238,7 @@ > if (sshpam_err != PAM_SUCCESS) > goto auth_fail; > buffer_put_cstring(&buffer, "OK"); >+ /* XXX - can't do much about an error here */ > ssh_msg_send(ctxt->pam_csock, sshpam_err, &buffer); > buffer_free(&buffer); > pthread_exit(NULL); >@@ -239,6 +246,7 @@ > auth_fail: > buffer_put_cstring(&buffer, > pam_strerror(sshpam_handle, sshpam_err)); >+ /* XXX - can't do much about an error here */ > ssh_msg_send(ctxt->pam_csock, PAM_AUTH_ERR, &buffer); > buffer_free(&buffer); > pthread_exit(NULL); >@@ -474,7 +482,10 @@ > } > buffer_init(&buffer); > buffer_put_cstring(&buffer, *resp); >- ssh_msg_send(ctxt->pam_psock, PAM_AUTHTOK, &buffer); >+ if (ssh_msg_send(ctxt->pam_psock, PAM_AUTHTOK, &buffer) == -1) { >+ buffer_free(&buffer); >+ return (-1); >+ } > buffer_free(&buffer); > return (1); > } >Index: msg.c >=================================================================== >RCS file: /var/cvs/openssh/msg.c,v >retrieving revision 1.7 >diff -u -r1.7 msg.c >--- msg.c 3 Jul 2003 03:46:57 -0000 1.7 >+++ msg.c 16 Nov 2003 23:12:18 -0000 >@@ -30,7 +30,7 @@ > #include "atomicio.h" > #include "msg.h" > >-void >+int > ssh_msg_send(int fd, u_char type, Buffer *m) > { > u_char buf[5]; >@@ -40,10 +40,15 @@ > > PUT_32BIT(buf, mlen + 1); > buf[4] = type; /* 1st byte of payload is mesg-type */ >- if (atomicio(vwrite, fd, buf, sizeof(buf)) != sizeof(buf)) >- fatal("ssh_msg_send: write"); >- if (atomicio(vwrite, fd, buffer_ptr(m), mlen) != mlen) >- fatal("ssh_msg_send: write"); >+ if (atomicio(vwrite, fd, buf, sizeof(buf)) != sizeof(buf)) { >+ error("ssh_msg_send: write"); >+ return (-1); >+ } >+ if (atomicio(vwrite, fd, buffer_ptr(m), mlen) != mlen) { >+ error("ssh_msg_send: write"); >+ return (-1); >+ } >+ return (0); > } > > int >@@ -57,17 +62,21 @@ > > res = atomicio(read, fd, buf, sizeof(buf)); > if (res != sizeof(buf)) { >- if (res == 0) >- return -1; >- fatal("ssh_msg_recv: read: header %ld", (long)res); >+ if (res != 0) >+ error("ssh_msg_recv: read: header %ld", (long)res); >+ return (-1); > } > msg_len = GET_32BIT(buf); >- if (msg_len > 256 * 1024) >- fatal("ssh_msg_recv: read: bad msg_len %u", msg_len); >+ if (msg_len > 256 * 1024) { >+ error("ssh_msg_recv: read: bad msg_len %u", msg_len); >+ return (-1); >+ } > buffer_clear(m); > buffer_append_space(m, msg_len); > res = atomicio(read, fd, buffer_ptr(m), msg_len); >- if (res != msg_len) >- fatal("ssh_msg_recv: read: %ld != msg_len", (long)res); >- return 0; >+ if (res != msg_len) { >+ error("ssh_msg_recv: read: %ld != msg_len", (long)res); >+ return (-1); >+ } >+ return (0); > } >Index: msg.h >=================================================================== >RCS file: /var/cvs/openssh/msg.h,v >retrieving revision 1.3 >diff -u -r1.3 msg.h >--- msg.h 23 Dec 2002 02:58:17 -0000 1.3 >+++ msg.h 16 Nov 2003 23:12:24 -0000 >@@ -25,7 +25,7 @@ > #ifndef SSH_MSG_H > #define SSH_MSG_H > >-void ssh_msg_send(int, u_char, Buffer *); >+int ssh_msg_send(int, u_char, Buffer *); > int ssh_msg_recv(int, Buffer *); > > #endif >Index: ssh-keysign.c >=================================================================== >RCS file: /var/cvs/openssh/ssh-keysign.c,v >retrieving revision 1.16 >diff -u -r1.16 ssh-keysign.c >--- ssh-keysign.c 3 Jul 2003 10:37:47 -0000 1.16 >+++ ssh-keysign.c 16 Nov 2003 23:20:31 -0000 >@@ -233,7 +233,8 @@ > /* send reply */ > buffer_clear(&b); > buffer_put_string(&b, signature, slen); >- ssh_msg_send(STDOUT_FILENO, version, &b); >+ if (ssh_msg_send(STDOUT_FILENO, version, &b) == -1) >+ fatal("ssh_msg_send failed"); > > return (0); > } >Index: sshconnect2.c >=================================================================== >RCS file: /var/cvs/openssh/sshconnect2.c,v >retrieving revision 1.117 >diff -u -r1.117 sshconnect2.c >--- sshconnect2.c 3 Nov 2003 09:09:03 -0000 1.117 >+++ sshconnect2.c 16 Nov 2003 23:19:58 -0000 >@@ -1248,7 +1248,8 @@ > buffer_init(&b); > buffer_put_int(&b, packet_get_connection_in()); /* send # of socket */ > buffer_put_string(&b, data, datalen); >- ssh_msg_send(to[1], version, &b); >+ if (ssh_msg_send(to[1], version, &b) == -1) >+ fatal("ssh_keysign: couldn't send request"); > > if (ssh_msg_recv(from[0], &b) < 0) { > error("ssh_keysign: no reply");
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 632
: 501