summaryrefslogtreecommitdiff
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 1ff7152a8..0e7d5cf58 100644
--- a/channels.c
+++ b/channels.c
@@ -249,7 +249,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
249 /* Do initial allocation if this is the first call. */ 249 /* Do initial allocation if this is the first call. */
250 if (channels_alloc == 0) { 250 if (channels_alloc == 0) {
251 channels_alloc = 10; 251 channels_alloc = 10;
252 channels = xmalloc(channels_alloc * sizeof(Channel *)); 252 channels = xcalloc(channels_alloc, sizeof(Channel *));
253 for (i = 0; i < channels_alloc; i++) 253 for (i = 0; i < channels_alloc; i++)
254 channels[i] = NULL; 254 channels[i] = NULL;
255 } 255 }
@@ -274,8 +274,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
274 channels[i] = NULL; 274 channels[i] = NULL;
275 } 275 }
276 /* Initialize and return new channel. */ 276 /* Initialize and return new channel. */
277 c = channels[found] = xmalloc(sizeof(Channel)); 277 c = channels[found] = xcalloc(1, sizeof(Channel));
278 memset(c, 0, sizeof(Channel));
279 buffer_init(&c->input); 278 buffer_init(&c->input);
280 buffer_init(&c->output); 279 buffer_init(&c->output);
281 buffer_init(&c->extended); 280 buffer_init(&c->extended);
@@ -2842,7 +2841,7 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost,
2842 } 2841 }
2843 2842
2844 /* Allocate a channel for each socket. */ 2843 /* Allocate a channel for each socket. */
2845 *chanids = xmalloc(sizeof(**chanids) * (num_socks + 1)); 2844 *chanids = xcalloc(num_socks + 1, sizeof(**chanids));
2846 for (n = 0; n < num_socks; n++) { 2845 for (n = 0; n < num_socks; n++) {
2847 sock = socks[n]; 2846 sock = socks[n];
2848 nc = channel_new("x11 listener", 2847 nc = channel_new("x11 listener",