len = 1024;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
- "ajp_msg_dump(): %s pos=%d len=%d max=%d",
- err, msg->pos, msg->len, AJP_MSG_BUFFER_SZ);
+ "ajp_msg_dump(): %s pos=%" APR_SIZE_T_FMT
+ " len=%" APR_SIZE_T_FMT " max=%d",
+ err, msg->pos, msg->len, AJP_MSG_BUFFER_SZ);
for (i = 0; i < len; i += 16) {
current = line;
*current++ = '\0';
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
- "ajp_msg_dump(): %.4x %s",
+ "ajp_msg_dump(): %.4lx %s",
i, line);
}
if (msglen > AJP_MSG_BUFFER_SZ) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_check_msg_header() incoming message is too big %d, max is %d",
- msglen, AJP_MSG_BUFFER_SZ);
+ "ajp_check_msg_header() incoming message is "
+ "too big %" APR_SIZE_T_FMT ", max is %d",
+ msglen, AJP_MSG_BUFFER_SZ);
return AJP_ETOBIG;
}
return APR_SUCCESS;
}
+static APR_INLINE int ajp_log_overflow(ajp_msg_t *msg, const char *context)
+{
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+ "%s(): BufferOverflowException %" APR_SIZE_T_FMT
+ " %" APR_SIZE_T_FMT,
+ context, msg->pos, msg->len);
+ return AJP_EOVERFLOW;
+}
+
/**
* Add an unsigned 32bits value to AJP Message
*
apr_size_t len = msg->len;
if ((len + 4) > AJP_MSG_BUFFER_SZ) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_append_uint32(): BufferOverflowException %d %d",
- msg->pos, msg->len);
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_append_uint32");
}
msg->buf[len] = (apr_byte_t)((value >> 24) & 0xFF);
apr_size_t len = msg->len;
if ((len + 2) > AJP_MSG_BUFFER_SZ) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_append_uint16(): BufferOverflowException %d %d",
- msg->pos, msg->len);
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_append_uint16");
}
msg->buf[len] = (apr_byte_t)((value >> 8) & 0xFF);
apr_size_t len = msg->len;
if ((len + 1) > AJP_MSG_BUFFER_SZ) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_append_uint8(): BufferOverflowException %d %d",
- msg->pos, msg->len);
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_append_uint8");
}
msg->buf[len] = value;
len = strlen(value);
if ((msg->len + len + 2) > AJP_MSG_BUFFER_SZ) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_append_cvt_string(): BufferOverflowException %d %d",
- msg->pos, msg->len);
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_append_cvt_string");
}
/* ignore error - we checked once */
}
if ((msg->len + valuelen) > AJP_MSG_BUFFER_SZ) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_append_bytes(): BufferOverflowException %d %d",
- msg->pos, msg->len);
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_append_bytes");
}
/* We checked for space !! */
apr_uint32_t value;
if ((msg->pos + 3) > msg->len) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_get_long(): BufferOverflowException %d %d",
- msg->pos, msg->len);
-
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_get_uint32");
}
value = ((msg->buf[(msg->pos++)] & 0xFF) << 24);
apr_uint16_t value;
if ((msg->pos + 1) > msg->len) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_get_int(): BufferOverflowException %d %d",
- msg->pos, msg->len);
-
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_get_uint16");
}
value = ((msg->buf[(msg->pos++)] & 0xFF) << 8);
apr_uint16_t value;
if ((msg->pos + 1) > msg->len) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_peek_int(): BufferOverflowException %d %d",
- msg->pos, msg->len);
-
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_peek_uint16");
}
value = ((msg->buf[(msg->pos)] & 0xFF) << 8);
apr_status_t ajp_msg_peek_uint8(ajp_msg_t *msg, apr_byte_t *rvalue)
{
if (msg->pos > msg->len) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_peek_uint8(): BufferOverflowException %d %d",
- msg->pos, msg->len);
-
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_peek_uint8");
}
*rvalue = msg->buf[msg->pos];
{
if (msg->pos > msg->len) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_get_uint8(): BufferOverflowException %d %d",
- msg->pos, msg->len);
-
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_get_uint8");
}
*rvalue = msg->buf[msg->pos++];
start = msg->pos;
if ((status != APR_SUCCESS) || (size + start > AJP_MSG_BUFFER_SZ)) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_get_string(): BufferOverflowException %d %d",
- msg->pos, msg->len);
-
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_get_string");
}
msg->pos += (apr_size_t)size;
start = msg->pos;
if ((status != APR_SUCCESS) || (size + start > AJP_MSG_BUFFER_SZ)) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_get_bytes(): BufferOverflowException %d %d",
- msg->pos, msg->len);
- return AJP_EOVERFLOW;
+ return ajp_log_overflow(msg, "ajp_msg_get_bytes");
}
msg->pos += (apr_size_t)size; /* only bytes, no trailer */
{
if (dmsg == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_copy(): destination msg is null");
+ "ajp_msg_copy(): destination msg is null");
return AJP_EINVAL;
}
if (smsg->len > AJP_MSG_BUFFER_SZ) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ajp_msg_copy(): destination buffer too small %d, max size is %d",
- smsg->len, AJP_MSG_BUFFER_SZ);
+ "ajp_msg_copy(): destination buffer too "
+ "small %" APR_SIZE_T_FMT ", max size is %d",
+ smsg->len, AJP_MSG_BUFFER_SZ);
return AJP_ETOSMALL;
}