OpenSSH
[Top] [All Lists]

[PATCH 3/6] auth-pam.c: Replace malloc+memset with calloc

To: openssh-unix-dev@mindrot.org
Subject: [PATCH 3/6] auth-pam.c: Replace malloc+memset with calloc
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Wed, 11 Apr 2007 03:39:55 +0400
Delivered-to: sp-com-lists@consult.net
Delivered-to: openssh-unix-dev-list1@securepoint.com
Delivered-to: openssh-unix-dev-tmda@mindrot.org
Delivered-to: openssh-unix-dev@mindrot.org
In-reply-to: <20070410233107.GA4984@nomad.office.altlinux.org>
List-archive: <http://lists.mindrot.org/pipermail/openssh-unix-dev>
List-help: <mailto:openssh-unix-dev-request@mindrot.org?subject=help>
List-id: Development of portable OpenSSH <openssh-unix-dev.mindrot.org>
List-post: <mailto:openssh-unix-dev@mindrot.org>
List-subscribe: <http://lists.mindrot.org/mailman/listinfo/openssh-unix-dev>, <mailto:openssh-unix-dev-request@mindrot.org?subject=subscribe>
List-unsubscribe: <http://lists.mindrot.org/mailman/listinfo/openssh-unix-dev>, <mailto:openssh-unix-dev-request@mindrot.org?subject=unsubscribe>
Mail-followup-to: openssh-unix-dev@mindrot.org
References: <20070410233107.GA4984@nomad.office.altlinux.org>
Sender: openssh-unix-dev-bounces+openssh-unix-dev-list1=securepoint.com@mindrot.org
---
 openssh/auth-pam.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

--- a/openssh/auth-pam.c
+++ b/openssh/auth-pam.c
@@ -686,8 +686,7 @@ sshpam_init_ctx(Authctxt *authctxt)
                return (NULL);
        }
 
-       ctxt = xmalloc(sizeof *ctxt);
-       memset(ctxt, 0, sizeof(*ctxt));
+       ctxt = xcalloc(1, sizeof *ctxt);
 
        /* Start the authentication thread */
        if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, socks) == -1) {
@@ -1131,9 +1130,8 @@ sshpam_passwd_conv(int n, sshpam_const struct pam_message 
**msg,
        if (n <= 0 || n > PAM_MAX_NUM_MSG)
                return (PAM_CONV_ERR);
 
-       if ((reply = malloc(n * sizeof(*reply))) == NULL)
+       if ((reply = calloc(n, sizeof(*reply))) == NULL)
                return (PAM_CONV_ERR);
-       memset(reply, 0, n * sizeof(*reply));
 
        for (i = 0; i < n; ++i) {
                switch (PAM_MSG_MEMBER(msg, i, msg_style)) {

-- 
ldv

Attachment: pgpuXD4SZRufE.pgp
Description: PGP signature

_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
http://lists.mindrot.org/mailman/listinfo/openssh-unix-dev
<Prev in Thread] Current Thread [Next in Thread>