[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#745866: FileFd::Size failure on all big-endian architectures



And, in case the explicit cast made you feel icky, this is a different
patch that also gets the job done, by keeping the 64-bit type, but
performing the byte swap correctly:

==============
--- apt-1.0.2ubuntu1/apt-pkg/contrib/fileutl.cc	2014-04-25 05:49:56.000000000 -0600
+++ apt-1.0.2ubuntu3/apt-pkg/contrib/fileutl.cc	2014-04-25 20:03:33.000000000 -0600
@@ -1888,10 +1888,7 @@
        }
 
 #ifdef WORDS_BIGENDIAN
-       uint32_t tmp_size = size;
-       uint8_t const * const p = (uint8_t const * const) &tmp_size;
-       tmp_size = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
-       size = tmp_size;
+       size = le64toh(size);
 #endif
 
        if (lseek(iFd, oldPos, SEEK_SET) < 0)
==============

Use whichever appeals more, either should fix the issue. :)

... Adam


Reply to: