Changeset 153cc76a in mainline for uspace/srv/net/tl/tcp/tcp.c


Ignore:
Timestamp:
2011-12-23T16:42:22Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7e1b130
Parents:
4291215 (diff), 2f0dd2a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Mainline changes.

File:
1 edited

Legend:

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

    r4291215 r153cc76a  
    3636
    3737#include <async.h>
     38#include <bitops.h>
    3839#include <byteorder.h>
    3940#include <errno.h>
     
    191192        tcp_pdu_t *pdu;
    192193        size_t hdr_size;
    193 
    194         /* XXX Header options */
    195         hdr_size = sizeof(tcp_header_t);
     194        tcp_header_t *hdr;
     195        uint32_t data_offset;
     196
     197        if (pdu_raw_size < sizeof(tcp_header_t)) {
     198                log_msg(LVL_WARN, "pdu_raw_size = %zu < sizeof(tcp_header_t) = %zu",
     199                    pdu_raw_size, sizeof(tcp_header_t));
     200                pq_release_remote(net_sess, packet_get_id(packet));
     201                return EINVAL;
     202        }
     203
     204        hdr = (tcp_header_t *)pdu_raw;
     205        data_offset = BIT_RANGE_EXTRACT(uint32_t, DF_DATA_OFFSET_h, DF_DATA_OFFSET_l,
     206            uint16_t_be2host(hdr->doff_flags));
     207
     208        hdr_size = sizeof(uint32_t) * data_offset;
    196209
    197210        if (pdu_raw_size < hdr_size) {
    198211                log_msg(LVL_WARN, "pdu_raw_size = %zu < hdr_size = %zu",
    199212                    pdu_raw_size, hdr_size);
     213                pq_release_remote(net_sess, packet_get_id(packet));
     214                return EINVAL;
     215        }
     216
     217        if (hdr_size < sizeof(tcp_header_t)) {
     218                log_msg(LVL_WARN, "hdr_size = %zu < sizeof(tcp_header_t) = %zu",
     219                    hdr_size, sizeof(tcp_header_t));
    200220                pq_release_remote(net_sess, packet_get_id(packet));
    201221                return EINVAL;
Note: See TracChangeset for help on using the changeset viewer.