fix etag/crc32b on bigendian
authorRemi Collet <remi@php.net>
Mon, 1 Sep 2014 13:42:34 +0000 (15:42 +0200)
committerMichael Wallner <mike@php.net>
Tue, 9 Sep 2014 07:52:25 +0000 (09:52 +0200)
php_http_etag.c

index 4562324af88ac1fa558c668f8d97060875a5f973..3604ad8673957f6ca4f52f35420fe06cb15eae14 100644 (file)
@@ -61,11 +61,15 @@ char *php_http_etag_finish(php_http_etag_t *e)
                unsigned char buf[4];
 
                *((uint *) e->ctx) = ~*((uint *) e->ctx);
+#ifdef WORDS_BIGENDIAN
+               etag = php_http_etag_digest((unsigned char *) e->ctx, 4);
+#else
                buf[0] = ((unsigned char *) e->ctx)[3];
                buf[1] = ((unsigned char *) e->ctx)[2];
                buf[2] = ((unsigned char *) e->ctx)[1];
                buf[3] = ((unsigned char *) e->ctx)[0];
                etag = php_http_etag_digest(buf, 4);
+#endif
        } else if ((!strcasecmp(e->mode, "sha1"))) {
                PHP_SHA1Final(digest, e->ctx);
                etag = php_http_etag_digest(digest, 20);