}
if (buf_len) {
- if ((len + buf_len) >= inl) {
+ /* Protected against len > MAX_INT
+ */
+ if ((len + (int)buf_len) >= inl || (int)buf_len < 0) {
/* we have enough to fill the buffer.
* append if we have already written to the buffer.
*/
char *value = (char *)buf+nibble;
int length = buf_len - nibble;
- memcpy((void*)in+len, buf, nibble);
+ memcpy(in + len, buf, nibble);
char_buffer_write(&inbio->cbuf, value, length);
len += nibble;
/* not enough data,
* save what we have and try to read more.
*/
- memcpy((void*)in+len, buf, buf_len);
+ memcpy(in + len, buf, buf_len);
len += buf_len;
}
}
char *buf,
apr_size_t *len)
{
- int wanted = *len;
- int bytes = 0, rc;
+ apr_size_t wanted = *len;
+ apr_size_t bytes = 0;
+ int rc;
*len = 0;
}
}
- rc = ssl_io_hook_read(ctx->frec->pssl, buf+bytes, wanted-bytes);
+ rc = ssl_io_hook_read(ctx->frec->pssl, buf + bytes, wanted - bytes);
if (rc > 0) {
*len += rc;
}
if (bytes > 0) {
+ /* Protected from truncation, bytes < MAX_SIZE_T */
if (bytes < len) {
- len = bytes;
+ len = (apr_size_t)bytes;
}
ctx->inbio.getline = 0;
status = ssl_io_input_read(ctx, ctx->buffer, &len);