diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2006-03-25 00:05:42 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2006-03-25 00:05:42 +0000 |
commit | 2deaa1649526d4ce68eed29e66d89d32fea75950 (patch) | |
tree | d92b455fbeda76727a52c07da67f7c2fbf210a5e /usr.bin/ssh/monitor.c | |
parent | 8748ab126c563a181843be1e20e74225a6c34369 (diff) |
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 'usr.bin/ssh/monitor.c')
-rw-r--r-- | usr.bin/ssh/monitor.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/usr.bin/ssh/monitor.c b/usr.bin/ssh/monitor.c index 18eb5a51072..92ae8875d27 100644 --- a/usr.bin/ssh/monitor.c +++ b/usr.bin/ssh/monitor.c @@ -1377,8 +1377,7 @@ mm_get_kex(Buffer *m) void *blob; u_int bloblen; - kex = xmalloc(sizeof(*kex)); - memset(kex, 0, sizeof(*kex)); + kex = xcalloc(1, sizeof(*kex)); kex->session_id = buffer_get_string(m, &kex->session_id_len); if ((session_id2 == NULL) || (kex->session_id_len != session_id2_len) || @@ -1543,9 +1542,8 @@ monitor_init(void) struct monitor *mon; int pair[2]; - mon = xmalloc(sizeof(*mon)); + mon = xcalloc(1, sizeof(*mon)); - mon->m_pid = 0; monitor_socketpair(pair); mon->m_recvfd = pair[0]; |