ssl/statem/statem_dtls.c:788: error: MEMORY_LEAK
  memory dynamically allocated by call to `pitem_new()` at line 784, column 16 is not reachable after line 788, column 9.
Showing all 87 steps of the trace


ssl/statem/statem_dtls.c:712:1: start of procedure dtls1_process_out_of_seq_message()
710.   }
711.   
712. > static int
713.   dtls1_process_out_of_seq_message(SSL *s, const struct hm_header_st *msg_hdr,
714.                                    int *ok)

ssl/statem/statem_dtls.c:716:5: 
714.                                    int *ok)
715.   {
716. >     int i = -1;
717.       hm_fragment *frag = NULL;
718.       pitem *item = NULL;

ssl/statem/statem_dtls.c:717:5: 
715.   {
716.       int i = -1;
717. >     hm_fragment *frag = NULL;
718.       pitem *item = NULL;
719.       unsigned char seq64be[8];

ssl/statem/statem_dtls.c:718:5: 
716.       int i = -1;
717.       hm_fragment *frag = NULL;
718. >     pitem *item = NULL;
719.       unsigned char seq64be[8];
720.       unsigned long frag_len = msg_hdr->frag_len;

ssl/statem/statem_dtls.c:720:5: 
718.       pitem *item = NULL;
719.       unsigned char seq64be[8];
720. >     unsigned long frag_len = msg_hdr->frag_len;
721.   
722.       if ((msg_hdr->frag_off + frag_len) > msg_hdr->msg_len)

ssl/statem/statem_dtls.c:722:9: Taking false branch
720.       unsigned long frag_len = msg_hdr->frag_len;
721.   
722.       if ((msg_hdr->frag_off + frag_len) > msg_hdr->msg_len)
               ^
723.           goto err;
724.   

ssl/statem/statem_dtls.c:726:5: 
724.   
725.       /* Try to find item in queue, to prevent duplicate entries */
726. >     memset(seq64be, 0, sizeof(seq64be));
727.       seq64be[6] = (unsigned char)(msg_hdr->seq >> 8);
728.       seq64be[7] = (unsigned char)msg_hdr->seq;

ssl/statem/statem_dtls.c:727:5: 
725.       /* Try to find item in queue, to prevent duplicate entries */
726.       memset(seq64be, 0, sizeof(seq64be));
727. >     seq64be[6] = (unsigned char)(msg_hdr->seq >> 8);
728.       seq64be[7] = (unsigned char)msg_hdr->seq;
729.       item = pqueue_find(s->d1->buffered_messages, seq64be);

ssl/statem/statem_dtls.c:728:5: 
726.       memset(seq64be, 0, sizeof(seq64be));
727.       seq64be[6] = (unsigned char)(msg_hdr->seq >> 8);
728. >     seq64be[7] = (unsigned char)msg_hdr->seq;
729.       item = pqueue_find(s->d1->buffered_messages, seq64be);
730.   

ssl/statem/statem_dtls.c:729:5: 
727.       seq64be[6] = (unsigned char)(msg_hdr->seq >> 8);
728.       seq64be[7] = (unsigned char)msg_hdr->seq;
729. >     item = pqueue_find(s->d1->buffered_messages, seq64be);
730.   
731.       /*

ssl/pqueue.c:149:1: start of procedure pqueue_find()
  147.   }
  148.   
  149. > pitem *pqueue_find(pqueue *pq, unsigned char *prio64be)
  150.   {
  151.       pitem *next;

ssl/pqueue.c:152:5: 
  150.   {
  151.       pitem *next;
  152. >     pitem *found = NULL;
  153.   
  154.       if (pq->items == NULL)

ssl/pqueue.c:154:9: Taking true branch
  152.       pitem *found = NULL;
  153.   
  154.       if (pq->items == NULL)
                 ^
  155.           return NULL;
  156.   

ssl/pqueue.c:155:9: 
  153.   
  154.       if (pq->items == NULL)
  155. >         return NULL;
  156.   
  157.       for (next = pq->items; next->next != NULL; next = next->next) {

ssl/pqueue.c:172:1: return from a call to pqueue_find
  170.   
  171.       return found;
  172. > }
  173.   
  174.   void pqueue_print(pqueue *pq)

ssl/statem/statem_dtls.c:735:9: Taking false branch
733.        * it and rather try to reassemble it.
734.        */
735.       if (item != NULL && frag_len != msg_hdr->msg_len)
               ^
736.           item = NULL;
737.   

ssl/statem/statem_dtls.c:743:9: Taking false branch
741.        * before the SERVER_HELLO, which then must be a stale retransmit.
742.        */
743.       if (msg_hdr->seq <= s->d1->handshake_read_seq ||
               ^
744.           msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL ||
745.           (s->d1->handshake_read_seq == 0 && msg_hdr->type == SSL3_MT_FINISHED))

ssl/statem/statem_dtls.c:744:9: Taking false branch
742.        */
743.       if (msg_hdr->seq <= s->d1->handshake_read_seq ||
744.           msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL ||
               ^
745.           (s->d1->handshake_read_seq == 0 && msg_hdr->type == SSL3_MT_FINISHED))
746.       {

ssl/statem/statem_dtls.c:744:58: Taking false branch
742.        */
743.       if (msg_hdr->seq <= s->d1->handshake_read_seq ||
744.           msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL ||
                                                                ^
745.           (s->d1->handshake_read_seq == 0 && msg_hdr->type == SSL3_MT_FINISHED))
746.       {

ssl/statem/statem_dtls.c:745:10: Taking false branch
743.       if (msg_hdr->seq <= s->d1->handshake_read_seq ||
744.           msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL ||
745.           (s->d1->handshake_read_seq == 0 && msg_hdr->type == SSL3_MT_FINISHED))
                ^
746.       {
747.           unsigned char devnull[256];

ssl/statem/statem_dtls.c:760:13: Taking false branch
758.           }
759.       } else {
760.           if (frag_len != msg_hdr->msg_len)
                   ^
761.               return dtls1_reassemble_fragment(s, msg_hdr, ok);
762.   

ssl/statem/statem_dtls.c:763:13: 
761.               return dtls1_reassemble_fragment(s, msg_hdr, ok);
762.   
763. >         if (frag_len > dtls1_max_handshake_message_len(s))
764.               goto err;
765.   

ssl/statem/statem_dtls.c:598:1: start of procedure dtls1_max_handshake_message_len()
  596.    * may be greater if the maximum certificate list size requires it.
  597.    */
  598. > static unsigned long dtls1_max_handshake_message_len(const SSL *s)
  599.   {
  600.       unsigned long max_len =

ssl/statem/statem_dtls.c:600:5: 
  598.   static unsigned long dtls1_max_handshake_message_len(const SSL *s)
  599.   {
  600. >     unsigned long max_len =
  601.           DTLS1_HM_HEADER_LENGTH + SSL3_RT_MAX_ENCRYPTED_LENGTH;
  602.       if (max_len < (unsigned long)s->max_cert_list)

ssl/statem/statem_dtls.c:602:9: Taking true branch
  600.       unsigned long max_len =
  601.           DTLS1_HM_HEADER_LENGTH + SSL3_RT_MAX_ENCRYPTED_LENGTH;
  602.       if (max_len < (unsigned long)s->max_cert_list)
                 ^
  603.           return s->max_cert_list;
  604.       return max_len;

ssl/statem/statem_dtls.c:603:9: 
  601.           DTLS1_HM_HEADER_LENGTH + SSL3_RT_MAX_ENCRYPTED_LENGTH;
  602.       if (max_len < (unsigned long)s->max_cert_list)
  603. >         return s->max_cert_list;
  604.       return max_len;
  605.   }

ssl/statem/statem_dtls.c:605:1: return from a call to dtls1_max_handshake_message_len
  603.           return s->max_cert_list;
  604.       return max_len;
  605. > }
  606.   
  607.   static int

ssl/statem/statem_dtls.c:763:13: Taking false branch
761.               return dtls1_reassemble_fragment(s, msg_hdr, ok);
762.   
763.           if (frag_len > dtls1_max_handshake_message_len(s))
                   ^
764.               goto err;
765.   

ssl/statem/statem_dtls.c:766:9: 
764.               goto err;
765.   
766. >         frag = dtls1_hm_fragment_new(frag_len, 0);
767.           if (frag == NULL)
768.               goto err;

ssl/statem/statem_dtls.c:162:1: start of procedure dtls1_hm_fragment_new()
  160.   static int dtls_get_reassembled_message(SSL *s, long *len);
  161.   
  162. > static hm_fragment *dtls1_hm_fragment_new(unsigned long frag_len,
  163.                                             int reassembly)
  164.   {

ssl/statem/statem_dtls.c:165:5: 
  163.                                             int reassembly)
  164.   {
  165. >     hm_fragment *frag = NULL;
  166.       unsigned char *buf = NULL;
  167.       unsigned char *bitmask = NULL;

ssl/statem/statem_dtls.c:166:5: 
  164.   {
  165.       hm_fragment *frag = NULL;
  166. >     unsigned char *buf = NULL;
  167.       unsigned char *bitmask = NULL;
  168.   

ssl/statem/statem_dtls.c:167:5: 
  165.       hm_fragment *frag = NULL;
  166.       unsigned char *buf = NULL;
  167. >     unsigned char *bitmask = NULL;
  168.   
  169.       frag = OPENSSL_malloc(sizeof(*frag));

ssl/statem/statem_dtls.c:169:5: 
  167.       unsigned char *bitmask = NULL;
  168.   
  169. >     frag = OPENSSL_malloc(sizeof(*frag));
  170.       if (frag == NULL)
  171.           return NULL;

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
    117.   }
    118.   
    119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121.       void *ret = NULL;

crypto/mem.c:121:5: 
    119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121. >     void *ret = NULL;
    122.   
    123.       if (num <= 0)

crypto/mem.c:123:9: Taking false branch
    121.       void *ret = NULL;
    122.   
    123.       if (num <= 0)
                   ^
    124.           return NULL;
    125.   

crypto/mem.c:126:5: 
    124.           return NULL;
    125.   
    126. >     allow_customize = 0;
    127.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    128.       if (call_malloc_debug) {

crypto/mem.c:136:5: 
    134.       }
    135.   #else
    136. >     (void)file;
    137.       (void)line;
    138.       ret = malloc(num);

crypto/mem.c:137:5: 
    135.   #else
    136.       (void)file;
    137. >     (void)line;
    138.       ret = malloc(num);
    139.   #endif

crypto/mem.c:138:5: 
    136.       (void)file;
    137.       (void)line;
    138. >     ret = malloc(num);
    139.   #endif
    140.   

crypto/mem.c:153:5: 
    151.   #endif
    152.   
    153. >     return ret;
    154.   }
    155.   

crypto/mem.c:154:1: return from a call to CRYPTO_malloc
    152.   
    153.       return ret;
    154. > }
    155.   
    156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

ssl/statem/statem_dtls.c:170:9: Taking false branch
  168.   
  169.       frag = OPENSSL_malloc(sizeof(*frag));
  170.       if (frag == NULL)
                 ^
  171.           return NULL;
  172.   

ssl/statem/statem_dtls.c:173:9: Taking true branch
  171.           return NULL;
  172.   
  173.       if (frag_len) {
                 ^
  174.           buf = OPENSSL_malloc(frag_len);
  175.           if (buf == NULL) {

ssl/statem/statem_dtls.c:174:9: 
  172.   
  173.       if (frag_len) {
  174. >         buf = OPENSSL_malloc(frag_len);
  175.           if (buf == NULL) {
  176.               OPENSSL_free(frag);

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
    117.   }
    118.   
    119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121.       void *ret = NULL;

crypto/mem.c:121:5: 
    119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121. >     void *ret = NULL;
    122.   
    123.       if (num <= 0)

crypto/mem.c:123:9: Taking false branch
    121.       void *ret = NULL;
    122.   
    123.       if (num <= 0)
                   ^
    124.           return NULL;
    125.   

crypto/mem.c:126:5: 
    124.           return NULL;
    125.   
    126. >     allow_customize = 0;
    127.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    128.       if (call_malloc_debug) {

crypto/mem.c:136:5: 
    134.       }
    135.   #else
    136. >     (void)file;
    137.       (void)line;
    138.       ret = malloc(num);

crypto/mem.c:137:5: 
    135.   #else
    136.       (void)file;
    137. >     (void)line;
    138.       ret = malloc(num);
    139.   #endif

crypto/mem.c:138:5: 
    136.       (void)file;
    137.       (void)line;
    138. >     ret = malloc(num);
    139.   #endif
    140.   

crypto/mem.c:153:5: 
    151.   #endif
    152.   
    153. >     return ret;
    154.   }
    155.   

crypto/mem.c:154:1: return from a call to CRYPTO_malloc
    152.   
    153.       return ret;
    154. > }
    155.   
    156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

ssl/statem/statem_dtls.c:175:13: Taking false branch
  173.       if (frag_len) {
  174.           buf = OPENSSL_malloc(frag_len);
  175.           if (buf == NULL) {
                     ^
  176.               OPENSSL_free(frag);
  177.               return NULL;

ssl/statem/statem_dtls.c:182:5: 
  180.   
  181.       /* zero length fragment gets zero frag->fragment */
  182. >     frag->fragment = buf;
  183.   
  184.       /* Initialize reassembly bitmask if necessary */

ssl/statem/statem_dtls.c:185:9: Taking false branch
  183.   
  184.       /* Initialize reassembly bitmask if necessary */
  185.       if (reassembly) {
                 ^
  186.           bitmask = OPENSSL_zalloc(RSMBLY_BITMASK_SIZE(frag_len));
  187.           if (bitmask == NULL) {

ssl/statem/statem_dtls.c:194:5: 
  192.       }
  193.   
  194. >     frag->reassembly = bitmask;
  195.   
  196.       return frag;

ssl/statem/statem_dtls.c:196:5: 
  194.       frag->reassembly = bitmask;
  195.   
  196. >     return frag;
  197.   }
  198.   

ssl/statem/statem_dtls.c:197:1: return from a call to dtls1_hm_fragment_new
  195.   
  196.       return frag;
  197. > }
  198.   
  199.   void dtls1_hm_fragment_free(hm_fragment *frag)

ssl/statem/statem_dtls.c:767:13: Taking false branch
765.   
766.           frag = dtls1_hm_fragment_new(frag_len, 0);
767.           if (frag == NULL)
                   ^
768.               goto err;
769.   

ssl/statem/statem_dtls.c:770:9: 
768.               goto err;
769.   
770. >         memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));
771.   
772.           if (frag_len) {

ssl/statem/statem_dtls.c:772:13: Taking true branch
770.           memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));
771.   
772.           if (frag_len) {
                   ^
773.               /*
774.                * read the body of the fragment (header has already been read

ssl/statem/statem_dtls.c:776:13: Skipping __function_pointer__(): unresolved function pointer
774.                * read the body of the fragment (header has already been read
775.                */
776.               i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL,
                   ^
777.                                             frag->fragment, frag_len, 0);
778.               if ((unsigned long)i != frag_len)

ssl/statem/statem_dtls.c:778:17: Taking false branch
776.               i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL,
777.                                             frag->fragment, frag_len, 0);
778.               if ((unsigned long)i != frag_len)
                       ^
779.                   i = -1;
780.               if (i <= 0)

ssl/statem/statem_dtls.c:780:17: Taking false branch
778.               if ((unsigned long)i != frag_len)
779.                   i = -1;
780.               if (i <= 0)
                       ^
781.                   goto err;
782.           }

ssl/statem/statem_dtls.c:784:9: 
782.           }
783.   
784. >         item = pitem_new(seq64be, frag);
785.           if (item == NULL)
786.               goto err;

ssl/pqueue.c:67:1: start of procedure pitem_new()
  65.   };
  66.   
  67. > pitem *pitem_new(unsigned char *prio64be, void *data)
  68.   {
  69.       pitem *item = OPENSSL_malloc(sizeof(*item));

ssl/pqueue.c:69:5: 
  67.   pitem *pitem_new(unsigned char *prio64be, void *data)
  68.   {
  69. >     pitem *item = OPENSSL_malloc(sizeof(*item));
  70.       if (item == NULL)
  71.           return NULL;

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
    117.   }
    118.   
    119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121.       void *ret = NULL;

crypto/mem.c:121:5: 
    119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121. >     void *ret = NULL;
    122.   
    123.       if (num <= 0)

crypto/mem.c:123:9: Taking false branch
    121.       void *ret = NULL;
    122.   
    123.       if (num <= 0)
                   ^
    124.           return NULL;
    125.   

crypto/mem.c:126:5: 
    124.           return NULL;
    125.   
    126. >     allow_customize = 0;
    127.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    128.       if (call_malloc_debug) {

crypto/mem.c:136:5: 
    134.       }
    135.   #else
    136. >     (void)file;
    137.       (void)line;
    138.       ret = malloc(num);

crypto/mem.c:137:5: 
    135.   #else
    136.       (void)file;
    137. >     (void)line;
    138.       ret = malloc(num);
    139.   #endif

crypto/mem.c:138:5: 
    136.       (void)file;
    137.       (void)line;
    138. >     ret = malloc(num);
    139.   #endif
    140.   

crypto/mem.c:153:5: 
    151.   #endif
    152.   
    153. >     return ret;
    154.   }
    155.   

crypto/mem.c:154:1: return from a call to CRYPTO_malloc
    152.   
    153.       return ret;
    154. > }
    155.   
    156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

ssl/pqueue.c:70:9: Taking false branch
  68.   {
  69.       pitem *item = OPENSSL_malloc(sizeof(*item));
  70.       if (item == NULL)
                ^
  71.           return NULL;
  72.   

ssl/pqueue.c:73:5: 
  71.           return NULL;
  72.   
  73. >     memcpy(item->priority, prio64be, sizeof(item->priority));
  74.   
  75.       item->data = data;

ssl/pqueue.c:75:5: 
  73.       memcpy(item->priority, prio64be, sizeof(item->priority));
  74.   
  75. >     item->data = data;
  76.       item->next = NULL;
  77.   

ssl/pqueue.c:76:5: 
  74.   
  75.       item->data = data;
  76. >     item->next = NULL;
  77.   
  78.       return item;

ssl/pqueue.c:78:5: 
  76.       item->next = NULL;
  77.   
  78. >     return item;
  79.   }
  80.   

ssl/pqueue.c:79:1: return from a call to pitem_new
  77.   
  78.       return item;
  79. > }
  80.   
  81.   void pitem_free(pitem *item)

ssl/statem/statem_dtls.c:785:13: Taking false branch
783.   
784.           item = pitem_new(seq64be, frag);
785.           if (item == NULL)
                   ^
786.               goto err;
787.   

ssl/statem/statem_dtls.c:788:9: Skipping pqueue_insert(): empty list of specs
786.               goto err;
787.   
788.           item = pqueue_insert(s->d1->buffered_messages, item);
               ^
789.           /*
790.            * pqueue_insert fails iff a duplicate item is inserted. However,

static int
dtls1_process_out_of_seq_message(SSL *s, const struct hm_header_st *msg_hdr,
                                 int *ok)
{
    int i = -1;
    hm_fragment *frag = NULL;
    pitem *item = NULL;
    unsigned char seq64be[8];
    unsigned long frag_len = msg_hdr->frag_len;
    if ((msg_hdr->frag_off + frag_len) > msg_hdr->msg_len)
        goto err;
    memset(seq64be, 0, sizeof(seq64be));
    seq64be[6] = (unsigned char)(msg_hdr->seq >> 8);
    seq64be[7] = (unsigned char)msg_hdr->seq;
    item = pqueue_find(s->d1->buffered_messages, seq64be);
    if (item != NULL && frag_len != msg_hdr->msg_len)
        item = NULL;
    if (msg_hdr->seq <= s->d1->handshake_read_seq ||
        msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL ||
        (s->d1->handshake_read_seq == 0 && msg_hdr->type == SSL3_MT_FINISHED))
    {
        unsigned char devnull[256];
        while (frag_len) {
            i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL,
                                          devnull,
                                          frag_len >
                                          sizeof(devnull) ? sizeof(devnull) :
                                          frag_len, 0);
            if (i <= 0)
                goto err;
            frag_len -= i;
        }
    } else {
        if (frag_len != msg_hdr->msg_len)
            return dtls1_reassemble_fragment(s, msg_hdr, ok);
        if (frag_len > dtls1_max_handshake_message_len(s))
            goto err;
        frag = dtls1_hm_fragment_new(frag_len, 0);
        if (frag == NULL)
            goto err;
        memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));
        if (frag_len) {
            i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL,
                                          frag->fragment, frag_len, 0);
            if ((unsigned long)i != frag_len)
                i = -1;
            if (i <= 0)
                goto err;
        }
        item = pitem_new(seq64be, frag);
        if (item == NULL)
            goto err;
        item = pqueue_insert(s->d1->buffered_messages, item);
        OPENSSL_assert(item != NULL);
    }
    return DTLS1_HM_FRAGMENT_RETRY;
 err:
    if (item == NULL)
        dtls1_hm_fragment_free(frag);
    *ok = 0;
    return i;
}
['static int\ndtls1_process_out_of_seq_message(SSL *s, const struct hm_header_st *msg_hdr,\n                                 int *ok)\n{\n    int i = -1;\n    hm_fragment *frag = NULL;\n    pitem *item = NULL;\n    unsigned char seq64be[8];\n    unsigned long frag_len = msg_hdr->frag_len;\n    if ((msg_hdr->frag_off + frag_len) > msg_hdr->msg_len)\n        goto err;\n    memset(seq64be, 0, sizeof(seq64be));\n    seq64be[6] = (unsigned char)(msg_hdr->seq >> 8);\n    seq64be[7] = (unsigned char)msg_hdr->seq;\n    item = pqueue_find(s->d1->buffered_messages, seq64be);\n    if (item != NULL && frag_len != msg_hdr->msg_len)\n        item = NULL;\n    if (msg_hdr->seq <= s->d1->handshake_read_seq ||\n        msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL ||\n        (s->d1->handshake_read_seq == 0 && msg_hdr->type == SSL3_MT_FINISHED))\n    {\n        unsigned char devnull[256];\n        while (frag_len) {\n            i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL,\n                                          devnull,\n                                          frag_len >\n                                          sizeof(devnull) ? sizeof(devnull) :\n                                          frag_len, 0);\n            if (i <= 0)\n                goto err;\n            frag_len -= i;\n        }\n    } else {\n        if (frag_len != msg_hdr->msg_len)\n            return dtls1_reassemble_fragment(s, msg_hdr, ok);\n        if (frag_len > dtls1_max_handshake_message_len(s))\n            goto err;\n        frag = dtls1_hm_fragment_new(frag_len, 0);\n        if (frag == NULL)\n            goto err;\n        memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));\n        if (frag_len) {\n            i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL,\n                                          frag->fragment, frag_len, 0);\n            if ((unsigned long)i != frag_len)\n                i = -1;\n            if (i <= 0)\n                goto err;\n        }\n        item = pitem_new(seq64be, frag);\n        if (item == NULL)\n            goto err;\n        item = pqueue_insert(s->d1->buffered_messages, item);\n        OPENSSL_assert(item != NULL);\n    }\n    return DTLS1_HM_FRAGMENT_RETRY;\n err:\n    if (item == NULL)\n        dtls1_hm_fragment_free(frag);\n    *ok = 0;\n    return i;\n}', 'pitem *pqueue_find(pqueue *pq, unsigned char *prio64be)\n{\n    pitem *next;\n    pitem *found = NULL;\n    if (pq->items == NULL)\n        return NULL;\n    for (next = pq->items; next->next != NULL; next = next->next) {\n        if (memcmp(next->priority, prio64be, 8) == 0) {\n            found = next;\n            break;\n        }\n    }\n    if (memcmp(next->priority, prio64be, 8) == 0)\n        found = next;\n    if (!found)\n        return NULL;\n    return found;\n}', 'static unsigned long dtls1_max_handshake_message_len(const SSL *s)\n{\n    unsigned long max_len =\n        DTLS1_HM_HEADER_LENGTH + SSL3_RT_MAX_ENCRYPTED_LENGTH;\n    if (max_len < (unsigned long)s->max_cert_list)\n        return s->max_cert_list;\n    return max_len;\n}', 'static hm_fragment *dtls1_hm_fragment_new(unsigned long frag_len,\n                                          int reassembly)\n{\n    hm_fragment *frag = NULL;\n    unsigned char *buf = NULL;\n    unsigned char *bitmask = NULL;\n    frag = OPENSSL_malloc(sizeof(*frag));\n    if (frag == NULL)\n        return NULL;\n    if (frag_len) {\n        buf = OPENSSL_malloc(frag_len);\n        if (buf == NULL) {\n            OPENSSL_free(frag);\n            return NULL;\n        }\n    }\n    frag->fragment = buf;\n    if (reassembly) {\n        bitmask = OPENSSL_zalloc(RSMBLY_BITMASK_SIZE(frag_len));\n        if (bitmask == NULL) {\n            OPENSSL_free(buf);\n            OPENSSL_free(frag);\n            return NULL;\n        }\n    }\n    frag->reassembly = bitmask;\n    return frag;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (num <= 0)\n        return NULL;\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'pitem *pitem_new(unsigned char *prio64be, void *data)\n{\n    pitem *item = OPENSSL_malloc(sizeof(*item));\n    if (item == NULL)\n        return NULL;\n    memcpy(item->priority, prio64be, sizeof(item->priority));\n    item->data = data;\n    item->next = NULL;\n    return item;\n}']