]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r517238, r517654 from trunk:
authorRuediger Pluem <rpluem@apache.org>
Sat, 8 Dec 2007 16:50:12 +0000 (16:50 +0000)
committerRuediger Pluem <rpluem@apache.org>
Sat, 8 Dec 2007 16:50:12 +0000 (16:50 +0000)
Generate etags consistently across 32-bit and 64-bit platforms:

* modules/http/http_etag.c (etag_uint64_to_hex): Renamed from
etag_ulong_to_hex; take an apr_uint64_t argument.
(ap_make_etag): Adjust to use new function and macro names.
Pass arguments directly to etag_uint64_to_hex without casting
down to unsigned long.

* modules/http/http_etag.c (etag_uint64_to_hex): Fix maximum shift
size, thanks to Ruediger.

PR: 40064
Submitted by: jorton
Reviewed by: rpluem, jim, niq

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@602503 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/http/http_etag.c

diff --git a/CHANGES b/CHANGES
index 577efad71a926a541246725fe895ab59b7be5276..78c6165d9ecaa7a0f04a0589b7568aeed12acb6d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.7
 
+  *) core: Change etag generation to produce identical results on
+     32-bit and 64-bit platforms.  PR 40064.  [Joe Orton]
+
   *) http_protocol: Escape request method in 413 error reporting.
      Determined to be not generally exploitable, but a flaw in any case.
      PR 44014 [Victor Stinner <victor.stinner inl.fr>]
diff --git a/STATUS b/STATUS
index 6a1768bfb6159c3d7d055a81c11c4ce2cc20504a..6a74ee91965d8a990ed4a881e05ac3bb43e8b369 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -89,16 +89,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
        http://people.apache.org/~jim/patches/reqtail-patch.txt
     +1: jim, rpluem, niq
 
-  * core: Change etag generation to produce identical results on
-          32-bit and 64-bit platforms.
-    PR 40064.
-    Trunk version of patch:
-       http://svn.apache.org/viewvc?view=rev&rev=517238
-       http://svn.apache.org/viewvc?view=rev&rev=517654
-    Backport version for 2.2.x of patch:
-       Trunk version of patch works
-    +1: rpluem, jim, niq
-
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
 
index c2dd88138aa37d321691493827a8db9f239cd7df..427ebc782880b5c916f9b8e62f65f0bb5de1d65d 100644 (file)
 #include "http_protocol.h"   /* For index_of_response().  Grump. */
 #include "http_request.h"
 
-/* Generate the human-readable hex representation of an unsigned long
- * (basically a faster version of 'sprintf("%lx")')
+/* Generate the human-readable hex representation of an apr_uint64_t
+ * (basically a faster version of 'sprintf("%llx")')
  */
 #define HEX_DIGITS "0123456789abcdef"
-static char *etag_ulong_to_hex(char *next, unsigned long u)
+static char *etag_uint64_to_hex(char *next, apr_uint64_t u)
 {
     int printing = 0;
-    int shift = sizeof(unsigned long) * 8 - 4;
+    int shift = sizeof(apr_uint64_t) * 8 - 4;
     do {
-        unsigned long next_digit = ((u >> shift) & (unsigned long)0xf);
+        unsigned short next_digit = ((u >> shift) & (apr_uint64_t)0xf);
         if (next_digit) {
             *next++ = HEX_DIGITS[next_digit];
             printing = 1;
@@ -47,12 +47,12 @@ static char *etag_ulong_to_hex(char *next, unsigned long u)
         }
         shift -= 4;
     } while (shift);
-    *next++ = HEX_DIGITS[u & (unsigned long)0xf];
+    *next++ = HEX_DIGITS[u & (apr_uint64_t)0xf];
     return next;
 }
 
 #define ETAG_WEAK "W/"
-#define CHARS_PER_UNSIGNED_LONG (sizeof(unsigned long) * 2)
+#define CHARS_PER_UINT64 (sizeof(apr_uint64_t) * 2)
 /*
  * Construct an entity tag (ETag) from resource information.  If it's a real
  * file, build in some of the file characteristics.  If the modification time
@@ -115,7 +115,7 @@ AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak)
          * FileETag keywords.
          */
         etag = apr_palloc(r->pool, weak_len + sizeof("\"--\"") +
-                          3 * CHARS_PER_UNSIGNED_LONG + 1);
+                          3 * CHARS_PER_UINT64 + 1);
         next = etag;
         if (weak) {
             while (*weak) {
@@ -125,21 +125,21 @@ AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak)
         *next++ = '"';
         bits_added = 0;
         if (etag_bits & ETAG_INODE) {
-            next = etag_ulong_to_hex(next, (unsigned long)r->finfo.inode);
+            next = etag_uint64_to_hex(next, r->finfo.inode);
             bits_added |= ETAG_INODE;
         }
         if (etag_bits & ETAG_SIZE) {
             if (bits_added != 0) {
                 *next++ = '-';
             }
-            next = etag_ulong_to_hex(next, (unsigned long)r->finfo.size);
+            next = etag_uint64_to_hex(next, r->finfo.size);
             bits_added |= ETAG_SIZE;
         }
         if (etag_bits & ETAG_MTIME) {
             if (bits_added != 0) {
                 *next++ = '-';
             }
-            next = etag_ulong_to_hex(next, (unsigned long)r->mtime);
+            next = etag_uint64_to_hex(next, r->mtime);
         }
         *next++ = '"';
         *next = '\0';
@@ -149,7 +149,7 @@ AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak)
          * Not a file document, so just use the mtime: [W/]"mtime"
          */
         etag = apr_palloc(r->pool, weak_len + sizeof("\"\"") +
-                          CHARS_PER_UNSIGNED_LONG + 1);
+                          CHARS_PER_UINT64 + 1);
         next = etag;
         if (weak) {
             while (*weak) {
@@ -157,7 +157,7 @@ AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak)
             }
         }
         *next++ = '"';
-        next = etag_ulong_to_hex(next, (unsigned long)r->mtime);
+        next = etag_uint64_to_hex(next, r->mtime);
         *next++ = '"';
         *next = '\0';
     }