Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 4a0bc99 in mainline


Ignore:
Timestamp:
2016-03-30T09:47:15Z (4 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
88ab6e9
Parents:
83e69b9
Message:

tcp_pdu_encode fixes

  • Test the return value of tcp_header_encode()
  • Do not leak npdu and npdu→header in error paths
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tcp/pdu.c

    r83e69b9 r4a0bc99  
    324324        size_t text_size;
    325325        uint16_t checksum;
     326        int rc;
    326327
    327328        npdu = tcp_pdu_new();
     
    331332        npdu->src = epp->local.addr;
    332333        npdu->dest = epp->remote.addr;
    333         tcp_header_encode(epp, seg, &npdu->header, &npdu->header_size);
     334        rc = tcp_header_encode(epp, seg, &npdu->header, &npdu->header_size);
     335        if (rc != EOK) {
     336                free(npdu);
     337                return rc;
     338        }
    334339
    335340        text_size = tcp_segment_text_size(seg);
    336341        npdu->text = calloc(1, text_size);
    337         if (npdu->text == NULL)
     342        if (npdu->text == NULL) {
     343                free(npdu->header);
     344                free(npdu);
    338345                return ENOMEM;
     346        }
    339347
    340348        npdu->text_size = text_size;
Note: See TracChangeset for help on using the changeset viewer.