From 8e1a1acb5d8fe73aa32ea02fccd537ce3b1891c9 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 1 Feb 2011 18:29:03 +0100 Subject: [PATCH] Changed: #1249 Endianness problems while access to disk or memory --- code/nel/src/misc/path.cpp | 20 ++++++++++++++++++++ code/nel/tools/misc/bnp_make/main.cpp | 18 ++++++++++++++++++ code/ryzom/client/src/login_patch.cpp | 16 ++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index 5e542bd58..ed4d99c96 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -1224,6 +1224,11 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse, fclose(Handle); return; } + +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nOffsetFromBegining); +#endif + nlfseek64 (Handle, nOffsetFromBegining, SEEK_SET); uint32 nNbFile; if (fread (&nNbFile, sizeof(uint32), 1, Handle) != 1) @@ -1231,6 +1236,11 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse, fclose(Handle); return; } + +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nNbFile); +#endif + for (uint32 i = 0; i < nNbFile; ++i) { // Progress bar @@ -1259,12 +1269,22 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse, fclose(Handle); return; } + +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nFileSize2); +#endif + uint32 nFilePos; if (fread (&nFilePos, sizeof(uint32), 1, Handle) != 1) { fclose(Handle); return; } + +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nFilePos); +#endif + string sTmp = toLower(string(FileName)); if (sTmp.empty()) { diff --git a/code/nel/tools/misc/bnp_make/main.cpp b/code/nel/tools/misc/bnp_make/main.cpp index 3ad117a18..cf0332d2a 100644 --- a/code/nel/tools/misc/bnp_make/main.cpp +++ b/code/nel/tools/misc/bnp_make/main.cpp @@ -154,6 +154,10 @@ struct BNPHeader return false; } +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nOffsetFromBegining); +#endif + if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0) { fclose (f); @@ -167,6 +171,10 @@ struct BNPHeader return false; } +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nNbFile); +#endif + for (uint32 i = 0; i < nNbFile; ++i) { uint8 nStringSize; @@ -189,11 +197,21 @@ struct BNPHeader fclose (f); return false; } + +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(tmpBNPFile.Size); +#endif + if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1) { fclose (f); return false; } + +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(tmpBNPFile.Pos); +#endif + Files.push_back (tmpBNPFile); } diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index 877c2963e..fa0ef7f57 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -1708,6 +1708,10 @@ bool CPatchManager::readBNPHeader(const string &SourceName, vector &Fi return false; } +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nOffsetFromBegining); +#endif + if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0) { fclose(f); @@ -1721,6 +1725,10 @@ bool CPatchManager::readBNPHeader(const string &SourceName, vector &Fi return false; } +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nNbFile); +#endif + for (uint32 i = 0; i < nNbFile; ++i) { uint8 nStringSize; @@ -1746,12 +1754,20 @@ bool CPatchManager::readBNPHeader(const string &SourceName, vector &Fi return false; } +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(tmpBNPFile.Size); +#endif + if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1) { fclose(f); return false; } +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(tmpBNPFile.Pos); +#endif + Files.push_back (tmpBNPFile); } fclose (f);