summaryrefslogtreecommitdiff
path: root/moduli.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 /moduli.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 'moduli.c')
-rw-r--r--moduli.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/moduli.c b/moduli.c
index d53806ea6..f6f15a2a4 100644
--- a/moduli.c
+++ b/moduli.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: moduli.c,v 1.12 2005/07/17 07:17:55 djm Exp $ */ 1/* $OpenBSD: moduli.c,v 1.13 2006/03/25 00:05:41 djm Exp $ */
2/* 2/*
3 * Copyright 1994 Phil Karn <karn@qualcomm.com> 3 * Copyright 1994 Phil Karn <karn@qualcomm.com>
4 * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com> 4 * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com>
@@ -301,21 +301,10 @@ gen_candidates(FILE *out, u_int32_t memory, u_int32_t power, BIGNUM *start)
301 largewords = (largememory << SHIFT_MEGAWORD); 301 largewords = (largememory << SHIFT_MEGAWORD);
302 } 302 }
303 303
304 TinySieve = calloc(tinywords, sizeof(u_int32_t)); 304 TinySieve = xcalloc(tinywords, sizeof(u_int32_t));
305 if (TinySieve == NULL) {
306 error("Insufficient memory for tiny sieve: need %u bytes",
307 tinywords << SHIFT_BYTE);
308 exit(1);
309 }
310 tinybits = tinywords << SHIFT_WORD; 305 tinybits = tinywords << SHIFT_WORD;
311 306
312 SmallSieve = calloc(smallwords, sizeof(u_int32_t)); 307 SmallSieve = xcalloc(smallwords, sizeof(u_int32_t));
313 if (SmallSieve == NULL) {
314 error("Insufficient memory for small sieve: need %u bytes",
315 smallwords << SHIFT_BYTE);
316 xfree(TinySieve);
317 exit(1);
318 }
319 smallbits = smallwords << SHIFT_WORD; 308 smallbits = smallwords << SHIFT_WORD;
320 309
321 /* 310 /*