From: Harlan Stenn Date: Thu, 28 Jun 2007 08:11:15 +0000 (-0400) Subject: More assertion checks and malloc()->emalloc(), courtesy of Calysto X-Git-Tag: NTP_4_2_5P57~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7b05bf5bced426e757edcf4a1599be4982057e7;p=thirdparty%2Fntp.git More assertion checks and malloc()->emalloc(), courtesy of Calysto bk: 46836d23YhfwZBJjeD906OxPGCeSdg --- diff --git a/ChangeLog b/ChangeLog index 4548fa40b..78fde708b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* More assertion checks and malloc()->emalloc(), courtesy of Calysto. * [Bug 864] Place ntpd service in maintenance mode if using SMF on Solaris * [Bug 862] includefile nesting; preserve phonelist on reconfig. * [Bug 604] ntpd regularly dies on linux/alpha. diff --git a/ntpd/ntp_crypto.c b/ntpd/ntp_crypto.c index 1627d6528..fc17c00dc 100644 --- a/ntpd/ntp_crypto.c +++ b/ntpd/ntp_crypto.c @@ -2006,10 +2006,13 @@ asn2ntp ( char *v; /* pointer to ASN1_TIME string */ struct tm tm; /* used to convert to NTP time */ + NTP_REQUIRE(asn1time != NULL); + NTP_REQUIRE(asn1time->data != NULL); + /* * Extract time string YYMMDDHHMMSSZ from ASN1 time structure. * Note that the YY, MM, DD fields start with one, the HH, MM, - * SS fiels start with zero and the Z character should be 'Z' + * SS fields start with zero and the Z character should be 'Z' * for UTC. Also note that years less than 50 map to years * greater than 100. Dontcha love ASN.1? Better than MIL-188. */ @@ -3095,6 +3098,8 @@ cert_parse( cnt = X509_get_ext_count(cert); for (i = 0; i < cnt; i++) { ext = X509_get_ext(cert, i); + NTP_INSIST(ext != NULL); + NTP_INSIST(ext->value != NULL); method = X509V3_EXT_get(ext); temp = OBJ_obj2nid(ext->object); switch (temp) { diff --git a/ntpd/ntp_data_structures.c b/ntpd/ntp_data_structures.c index e1a4b7aca..a6539f32e 100644 --- a/ntpd/ntp_data_structures.c +++ b/ntpd/ntp_data_structures.c @@ -23,7 +23,7 @@ queue *create_priority_queue(int (*get_order)(void *, void *)) { - queue *my_queue = (queue *) malloc(sizeof(queue)); + queue *my_queue = (queue *) emalloc(sizeof(queue)); my_queue->get_order = get_order; my_queue->front = NULL; my_queue->no_of_elements = 0; @@ -59,7 +59,7 @@ void destroy_queue(queue *my_queue) void *get_node(size_t size) { node *new_node; - new_node = (node *) malloc(sizeof(node) + size); + new_node = (node *) emalloc(sizeof(node) + size); if (new_node != NULL) { new_node->node_next = NULL; return new_node + 1;