Roxen.git / server / protocols / http.pike

version» Context lines:

Roxen.git/server/protocols/http.pike:684:   //! @param fragment   //! Some incremental data received from the client.   //!   //! @returns   //! @int   //! @value 0   //! More data needed.   //! @value 1   //! Failure (not used).   //! @value 2 - //! Done and handled (not used). + //! Done and handled. + //! Returned on running into the request_data_max limit.   //! @value 3   //! Processing done.   //! @endint   private int got_chunk_fragment(string fragment)   {   #ifdef CONNECTION_DEBUG    werror("HTTP[%s]: Fragment (length %d+%d/%d) ============================\n"    "%O\n", DEBUG_GET_FD,    sizeof(fragment), sizeof(misc->chunk_buf||""), misc->chunk_len,    fragment);
Roxen.git/server/protocols/http.pike:715:    } else {    data_buffer->add(fragment[..misc->chunk_len - 1]);    chunk_offset = misc->chunk_len;    misc->chunk_len = 0;    }    } else {    buf = misc->chunk_buf + buf;    }    misc->chunk_buf = "";    +  int buf_max = port_obj->query("request_data_max"); +     while(misc->chunked == 1) {    int chunk_data_offset;    string chunk_extras;    int n = sscanf(buf, "%" + chunk_offset + "*s%x%s\r\n%n",    misc->chunk_len, chunk_extras,    chunk_data_offset);    if (n < 4) {    misc->chunk_buf = buf[chunk_offset..];    misc->chunk_len = 0;    return 0; // More data needed to parse the chunk length.    }      #ifdef CONNECTION_DEBUG    werror("HTTP[%s]: Got chunk with %d bytes of data.\n",    DEBUG_GET_FD, misc->chunk_len);   #endif       // FIXME: Currently we ignore the chunk_extras.    -  +  if (max) { +  int payload_size = +  ((data_buffer && sizeof(data_buffer)) + misc->chunk_len); +  if (max < payload_size) { + #ifdef CONNECTION_DEBUG +  werror("HTTP[%s]: Got too much chunked data.\n", DEBUG_GET_FD); + #endif +  send_size_error(payload_size, max); +  return 2; +  } +  } +     if (sizeof(buf) < chunk_data_offset + misc->chunk_len) {    if (!data_buffer) {    // The 16384 is some reasonable extra padding to    // avoid having to realloc.    data_buffer =    String.Buffer(sizeof(data) + misc->chunk_len + 16384);    if (sizeof(data)) data_buffer->add(data);    data = "";    }    data_buffer->add(buf[chunk_data_offset..]);
Roxen.git/server/protocols/http.pike:1198:    ready_to_receive();    TIMER_END(parse_got_2_more_data);    TIMER_END(parse_got_2);    return ret;    }    } else if(misc->len)    {    int l = misc->len;    wanted_data=l;    have_data=strlen(data); -  +  int max = port_obj->query("request_data_max"); +  if (max && (max < l)) { +  REQUEST_WERR(sprintf("HTTP: Request data (%d bytes) larger than configured limit (%d bytes).", +  l, max)); +  send_size_error(l, max); +  TIMER_END(parse_got_2_more_data); +  TIMER_END(parse_got_2); +  protocol_time += gethrtime() - start_time; +  return 2; +  }    if(strlen(data) < l)    {    REQUEST_WERR(sprintf("HTTP: More data needed in %s.", method));    ready_to_receive();    TIMER_END(parse_got_2_more_data);    TIMER_END(parse_got_2);    return 0;    }    leftovers = data[l+2..];    data = data[..l+1];