pike.git / lib / modules / SSL.pmod / Connection.pike

version» Context lines:

pike.git/lib/modules/SSL.pmod/Connection.pike:690:    send_packet(Packet(version, PACKET_application_data, data[..0]));    data = data[1..];    }       send_packet(Packet(version, PACKET_application_data,    data[..session->max_packet_size-1]));;    sent += size;    return size;   }    - protected int handle_alert(string s) + // @returns + // @int + // @elem value -1 + // A Fatal error occurred and processing should stop. + // @elem value 0 + // Processing can continue. + // @elem value 1 + // Connection should close. + // @endint + protected int(-1..1) handle_alert(string s)   {    // sizeof(s)==2, checked at caller.    int level = s[0];    int description = s[1];    COND_FATAL(!(ALERT_levels[level] && ALERT_descriptions[description]),    ALERT_unexpected_message, "Invalid alert\n");       if (level == ALERT_fatal)    {    SSL3_DEBUG_MSG("SSL.Connection: Fatal alert %O\n",
pike.git/lib/modules/SSL.pmod/Connection.pike:854:    SSL3_DEBUG_MSG("SSL.Connection: Heartbeat roundtrip: %dus\n", delta);   #endif    }    break;    default:    break;    }   }      Stdio.Buffer handshake_buffer = Stdio.Buffer(); // Error mode 0. - string(8bit) alert_buffer = ""; + Stdio.Buffer alert_buffer = Stdio.Buffer();      //! Main receive handler.   //!   //! @param data   //! String of data received from the peer.   //!   //! @returns   //! Returns one of:   //! @mixed   //! @type string(zero)
pike.git/lib/modules/SSL.pmod/Connection.pike:937:    packet->content_type);    switch (packet->content_type)    {    case PACKET_alert:    {    SSL3_DEBUG_MSG("SSL.Connection: ALERT\n");       COND_FATAL(!sizeof(packet->fragment), ALERT_unexpected_message,    "Zero length Alert fragments not allowed.\n");    -  int i; +     int err = 0; -  alert_buffer += packet->fragment; -  for (i = 0; -  !err && ((sizeof(alert_buffer) - i) >= 2); -  i+= 2) -  err = handle_alert(alert_buffer[i..i+1]); +  alert_buffer->add( packet->fragment ); +  while(!err && sizeof(alert_buffer)>1) +  err = handle_alert(alert_buffer->read(2));    -  alert_buffer = alert_buffer[i..]; +     if (err)    if (err > 0 && sizeof (res))    // If we get a close then we return the data we got so far.    return res;    else    return err;    break;    }    case PACKET_change_cipher_spec:    {