summaryrefslogtreecommitdiffstats
path: root/channels.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2006-03-26 14:19:21 +1100
committerDamien Miller <djm@mindrot.org>2006-03-26 14:19:21 +1100
commit07d86bec5eeaf19fe33dca99c8ebcbe9a77c3938 (patch)
tree098295eee2d7ec7b116b0db3ac4b580713dd5ab0 /channels.c
parent7cd4579eb3c5afd22ae24436fd2611cd3aa0150a (diff)
- djm@cvs.openbsd.org 2006/03/25 00:05:41
[auth-bsdauth.c auth-skey.c auth.c auth2-chall.c channels.c] [clientloop.c deattack.c gss-genr.c kex.c key.c misc.c moduli.c] [monitor.c monitor_wrap.c packet.c scard.c sftp-server.c ssh-agent.c] [ssh-keyscan.c ssh.c sshconnect.c sshconnect2.c sshd.c uuencode.c] [xmalloc.c xmalloc.h] introduce xcalloc() and xasprintf() failure-checked allocations functions and use them throughout openssh xcalloc is particularly important because malloc(nmemb * size) is a dangerous idiom (subject to integer overflow) and it is time for it to die feedback and ok deraadt@
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/channels.c b/channels.c
index 1ff7152a..0e7d5cf5 100644
--- a/channels.c
+++ b/channels.c
@@ -249,7 +249,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
/* Do initial allocation if this is the first call. */
if (channels_alloc == 0) {
channels_alloc = 10;
- channels = xmalloc(channels_alloc * sizeof(Channel *));
+ channels = xcalloc(channels_alloc, sizeof(Channel *));
for (i = 0; i < channels_alloc; i++)
channels[i] = NULL;
}
@@ -274,8 +274,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
channels[i] = NULL;
}
/* Initialize and return new channel. */
- c = channels[found] = xmalloc(sizeof(Channel));
- memset(c, 0, sizeof(Channel));
+ c = channels[found] = xcalloc(1, sizeof(Channel));
buffer_init(&c->input);
buffer_init(&c->output);
buffer_init(&c->extended);
@@ -2842,7 +2841,7 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost,
}
/* Allocate a channel for each socket. */
- *chanids = xmalloc(sizeof(**chanids) * (num_socks + 1));
+ *chanids = xcalloc(num_socks + 1, sizeof(**chanids));
for (n = 0; n < num_socks; n++) {
sock = socks[n];
nc = channel_new("x11 listener",