From: Harlan Stenn Date: Sat, 23 Jun 2007 04:38:42 +0000 (-0400) Subject: Add more assertions (Calypso) X-Git-Tag: NTP_4_2_5P55~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5db102e76899abe6916c7fe8b9c23bd5e4cce090;p=thirdparty%2Fntp.git Add more assertions (Calypso) bk: 467ca3d2rmTq6xZW_LXHi9SKHkFssA --- diff --git a/util/ntp-keygen.c b/util/ntp-keygen.c index ec7499bb8..54d52a9bf 100644 --- a/util/ntp-keygen.c +++ b/util/ntp-keygen.c @@ -160,6 +160,7 @@ u_long asn2ntp (ASN1_TIME *); * Program variables */ extern char *optarg; /* command line argument */ +char *progname; int debug = 0; /* debug, not de bug */ int rval; /* return status */ #ifdef OPENSSL @@ -247,6 +248,8 @@ main( #endif /* OPENSSL */ char hostbuf[MAXHOSTNAME + 1]; + progname = argv[0]; + #ifdef SYS_WINNT /* Initialize before OpenSSL checks */ InitWin32Sockets(); @@ -557,7 +560,7 @@ main( char *tld; sptr = strrchr(filename, '.'); - tld = malloc(strlen(sptr)); /* we have an extra byte ... */ + tld = emalloc(strlen(sptr)); /* we have an extra byte ... */ strcpy(tld, 1+sptr); /* ... see? */ sprintf(filename, "ntpkey_IFFkey_%s.%s", trustname, tld); @@ -1224,8 +1227,8 @@ gen_mv( dsa->p = BN_new(); dsa->q = BN_new(); dsa->g = BN_new(); - s = malloc((n + 1) * sizeof(BIGNUM)); - s1 = malloc((n + 1) * sizeof(BIGNUM)); + s = emalloc((n + 1) * sizeof(BIGNUM)); + s1 = emalloc((n + 1) * sizeof(BIGNUM)); for (j = 1; j <= n; j++) s1[j] = BN_new(); temp = 0; @@ -1325,7 +1328,7 @@ gen_mv( fprintf(stderr, "Generating polynomial coefficients for %d roots (%d bits)\n", n, BN_num_bits(dsa->q)); - x = malloc((n + 1) * sizeof(BIGNUM)); + x = emalloc((n + 1) * sizeof(BIGNUM)); for (j = 1; j <= n; j++) { x[j] = BN_new(); while (1) { @@ -1342,7 +1345,7 @@ gen_mv( * expansion of root products (x - x[j]) mod q for all j. The * method is a present from Charlie Boncelet. */ - a = malloc((n + 1) * sizeof(BIGNUM)); + a = emalloc((n + 1) * sizeof(BIGNUM)); for (i = 0; i <= n; i++) { a[i] = BN_new(); BN_one(a[i]); @@ -1363,7 +1366,7 @@ gen_mv( * Generate g[i] = g^a[i] mod p for all i and the generator g. */ fprintf(stderr, "Generating g[i] parameters\n"); - g = malloc((n + 1) * sizeof(BIGNUM)); + g = emalloc((n + 1) * sizeof(BIGNUM)); for (i = 0; i <= n; i++) { g[i] = BN_new(); BN_mod_exp(g[i], dsa->g, a[i], dsa->p, ctx); @@ -1431,8 +1434,8 @@ gen_mv( * or the product s = prod(s'[j]) mod q, which is the enabling * key. */ - xbar = malloc((n + 1) * sizeof(BIGNUM)); - xhat = malloc((n + 1) * sizeof(BIGNUM)); + xbar = emalloc((n + 1) * sizeof(BIGNUM)); + xhat = emalloc((n + 1) * sizeof(BIGNUM)); for (j = 1; j <= n; j++) { xbar[j] = BN_new(); xhat[j] = BN_new(); BN_zero(xbar[j]);