Ticket #6789: tcp-wrong-comparison.patch

File tcp-wrong-comparison.patch, 1.1 KB (added by kaliber, 13 years ago)

proposed patch

  • src/add-ons/kernel/network/protocols/tcp/tcp.cpp

     
    198198                length = 1;
    199199                break;
    200200            case TCP_OPTION_MAX_SEGMENT_SIZE:
    201                 if (option->length == 4 && (size - 4) >= 0)
     201                if (option->length == 4 && size >= 4)
    202202                    segment.max_segment_size = ntohs(option->max_segment_size);
    203203                break;
    204204            case TCP_OPTION_WINDOW_SHIFT:
    205                 if (option->length == 3 && (size - 3) >= 0) {
     205                if (option->length == 3 && size >= 3) {
    206206                    segment.options |= TCP_HAS_WINDOW_SCALE;
    207207                    segment.window_shift = option->window_shift;
    208208                }
    209209                break;
    210210            case TCP_OPTION_TIMESTAMP:
    211                 if (option->length == 10 && (size - 10) >= 0) {
     211                if (option->length == 10 && size >= 10) {
    212212                    segment.options |= TCP_HAS_TIMESTAMPS;
    213213                    segment.timestamp_value = option->timestamp.value;
    214214                    segment.timestamp_reply =
     
    216216                }
    217217                break;
    218218            case TCP_OPTION_SACK_PERMITTED:
    219                 if (option->length == 2 && (size - 2) >= 0)
     219                if (option->length == 2 && size >= 2)
    220220                    segment.options |= TCP_SACK_PERMITTED;
    221221        }
    222222