]> granicus.if.org Git - apache/commitdiff
Fix format string warnings in proxy_ajp on 64-bit platforms:
authorJoe Orton <jorton@apache.org>
Sat, 11 Sep 2004 09:57:12 +0000 (09:57 +0000)
committerJoe Orton <jorton@apache.org>
Sat, 11 Sep 2004 09:57:12 +0000 (09:57 +0000)
* modules/proxy/ajp_header.c (ajp_send_data_msg): Use
APR_SIZE_T_FMT.

* modules/proxy/ajp_link.c (ajp_ilink_receive): Don't pass
\n to ap_log_error; do use APR_SIZE_T_FMT.

* modules/proxy/ajp_msg.c (ajp_msg_dump, ajp_msg_check_header,
ajp_msg_copy): Use APR_SIZE_T_FMT.
(ajp_log_overflow): New function.
(ajp_msg_{append,peek,get}_*): Use it.

* modules/proxy/proxy_ajp.c (ap_proxy_ajp_request): Use
APR_SIZE_T_FMT.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105071 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/ajp_header.c
modules/proxy/ajp_link.c
modules/proxy/ajp_msg.c
modules/proxy/proxy_ajp.c

index 2948c7313b20b76c97d71a0481cba64bb1bc1b41..29fc4d6180c3c064ccdd746a8669bee7f5b39945 100644 (file)
@@ -712,7 +712,7 @@ apr_status_t  ajp_send_data_msg(apr_socket_t *sock, request_rec  *r,
     msg->len += len + 2; /* + 1 XXXX where is '\0' */
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-               "ajp_send_data_msg: sending %d", len);
+               "ajp_send_data_msg: sending %" APR_SIZE_T_FMT, len);
 
     rc = ajp_ilink_send(sock, msg);
     if (rc != APR_SUCCESS) {
index 21701da9ef509e3a2e27119ee2d2428600db05d6..5f8814131ed23bd7e77d8b9d86617c0d82dd21da 100644 (file)
@@ -102,7 +102,7 @@ apr_status_t ajp_ilink_receive(apr_socket_t *sock, ajp_msg_t *msg)
     
     if (status != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, status, NULL,
-                "ajp_ilink_receive() can't receive header\n");
+                     "ajp_ilink_receive() can't receive header");
         return AJP_ENO_HEADER;
     }
     
@@ -110,7 +110,7 @@ apr_status_t ajp_ilink_receive(apr_socket_t *sock, ajp_msg_t *msg)
 
     if (status != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
-                      "ajp_ilink_receive() received bad header\n");
+                     "ajp_ilink_receive() received bad header");
         return AJP_EBAD_HEADER;
     }
 
@@ -118,13 +118,15 @@ apr_status_t ajp_ilink_receive(apr_socket_t *sock, ajp_msg_t *msg)
 
     if (status != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, status, NULL,
-                      "ajp_ilink_receive() error while receiving message body of length %d\n",
-                      hlen);
+                     "ajp_ilink_receive() error while receiving message body "
+                     "of length %" APR_SIZE_T_FMT,
+                     hlen);
         return AJP_EBAD_MESSAGE;
     }
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
-                  "ajp_ilink_receive() received packet len=%d type=%d\n",
+                 "ajp_ilink_receive() received packet len=%" APR_SIZE_T_FMT
+                 "type=%d\n",
                   blen, (int)msg->buf[hlen]);
 
     return APR_SUCCESS;
index 3128d933b0b6de02cbd81e7ae621ec970773c902..2b5b4b80393fbe9465bd51e3fa3e6bc27566e041 100644 (file)
@@ -38,8 +38,9 @@ apr_status_t ajp_msg_dump(ajp_msg_t *msg, char *err)
         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;
@@ -68,7 +69,7 @@ apr_status_t ajp_msg_dump(ajp_msg_t *msg, char *err)
         *current++ = '\0';
 
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
-                      "ajp_msg_dump(): %.4x    %s",
+                      "ajp_msg_dump(): %.4lx    %s",
                       i, line);
     }
     
@@ -103,8 +104,9 @@ apr_status_t ajp_msg_check_header(ajp_msg_t *msg, apr_size_t *len)
 
     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;
     }
 
@@ -154,6 +156,15 @@ apr_status_t ajp_msg_end(ajp_msg_t *msg)
     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
  *
@@ -166,10 +177,7 @@ apr_status_t ajp_msg_append_uint32(ajp_msg_t *msg, apr_uint32_t value)
     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);
@@ -194,10 +202,7 @@ apr_status_t ajp_msg_append_uint16(ajp_msg_t *msg, apr_uint16_t value)
     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);
@@ -220,10 +225,7 @@ apr_status_t ajp_msg_append_uint8(ajp_msg_t *msg, apr_byte_t value)
     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;
@@ -252,10 +254,7 @@ apr_status_t ajp_msg_append_string_ex(ajp_msg_t *msg, const char *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 */
@@ -288,10 +287,7 @@ apr_status_t ajp_msg_append_bytes(ajp_msg_t *msg, const apr_byte_t *value,
     }
 
     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 !!  */
@@ -313,11 +309,7 @@ apr_status_t ajp_msg_get_uint32(ajp_msg_t *msg, apr_uint32_t *rvalue)
     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);
@@ -342,11 +334,7 @@ apr_status_t ajp_msg_get_uint16(ajp_msg_t *msg, apr_uint16_t *rvalue)
     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);
@@ -369,11 +357,7 @@ apr_status_t ajp_msg_peek_uint16(ajp_msg_t *msg, apr_uint16_t *rvalue)
     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);
@@ -394,11 +378,7 @@ apr_status_t ajp_msg_peek_uint16(ajp_msg_t *msg, apr_uint16_t *rvalue)
 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];
@@ -416,11 +396,7 @@ apr_status_t ajp_msg_get_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_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++];
@@ -445,11 +421,7 @@ apr_status_t ajp_msg_get_string(ajp_msg_t *msg, char **rvalue)
     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;
@@ -480,10 +452,7 @@ apr_status_t ajp_msg_get_bytes(ajp_msg_t *msg, apr_byte_t **rvalue,
     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 */
 
@@ -545,14 +514,15 @@ apr_status_t ajp_msg_copy(ajp_msg_t *smsg, ajp_msg_t *dmsg)
 {
     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;
     }
 
index 7cc2675de7fe9677c7e258f8d3f825c27612bbd0..69a525ef8c52eda136ff8307b8e70c074c02928e 100644 (file)
@@ -175,7 +175,8 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
 
         /* Try to send something */
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                     "proxy: data to read (max %d at %d)", bufsiz, msg->pos);
+                     "proxy: data to read (max %" APR_SIZE_T_FMT 
+                     " at %" APR_SIZE_T_FMT ")", bufsiz, msg->pos);
 
         status = apr_brigade_flatten(input_brigade, buff, &bufsiz);
         if (status != APR_SUCCESS) {
@@ -187,7 +188,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
         apr_brigade_cleanup(input_brigade);
 
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                     "proxy: got %d byte of data", bufsiz);
+                     "proxy: got %" APR_SIZE_T_FMT " bytes of data", bufsiz);
         if (bufsiz > 0) {
             status = ajp_send_data_msg(conn->sock, r, msg, bufsiz);
             if (status != APR_SUCCESS) {