For PR804:
authorReid Spencer <rspencer@reidspencer.com>
Thu, 8 Jun 2006 17:00:08 +0000 (17:00 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Thu, 8 Jun 2006 17:00:08 +0000 (17:00 +0000)
Change the file size field of StatusInfo to be uint64_t instead of size_t
so that we know it is always 64 bits. This prevents some overflow on
systems where size_t is 32 bits when it ought to be 64.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28726 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Path.h
lib/System/Win32/Path.inc

index 5cbca9b31a953bc9d386a888a5e01a7c36a0c46e..bd3a5dffae5a380b39c4e26b5ca75e28b0bf4225 100644 (file)
@@ -67,7 +67,7 @@ namespace sys {
       struct StatusInfo {
         StatusInfo() : fileSize(0), modTime(0,0), mode(0777), user(999),
                        group(999), isDir(false) { }
-        size_t      fileSize;   ///< Size of the file in bytes
+        uint64_t    fileSize;   ///< Size of the file in bytes
         TimeValue   modTime;    ///< Time of file's modification
         uint32_t    mode;       ///< Mode of the file, if applicable
         uint32_t    user;       ///< User ID of owner, if applicable
index f7be77f8c90945b5263b82ecf2ca0a4e86013c4c..4aab2765488108dfc9f73128fff837ee3527edfd 100644 (file)
@@ -340,7 +340,7 @@ Path::getStatusInfo(StatusInfo& info) const {
     ThrowError("getStatusInfo():" + std::string(path) + ": Can't get status: ");
 
   info.fileSize = fi.nFileSizeHigh;
-  info.fileSize <<= 32;
+  info.fileSize <<= sizeof(fi.nFileSizeHigh)*8;
   info.fileSize += fi.nFileSizeLow;
 
   info.mode = fi.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0555 : 0777;