diff options
author | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-01-28 00:31:00 +0000 |
---|---|---|
committer | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-01-28 00:31:00 +0000 |
commit | cb0f89646f065800d38d7cfc10ba1e855563296a (patch) | |
tree | 2cef9a44c911d1a80ef48bc74d50e7cc86b512b9 /serialize.h | |
parent | 9a36562347122482fd1e6e77c74df66ad8cf2c3f (diff) |
simplify AddAddress,
readcompactsize limit,
fixed a 64-bit compile error in serialize.h,
change status "# blocks" to "# confirmations" and widen the column.
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@53 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'serialize.h')
-rw-r--r-- | serialize.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/serialize.h b/serialize.h index ce4aff3cda..263a22677d 100644 --- a/serialize.h +++ b/serialize.h @@ -20,7 +20,7 @@ class CDataStream; class CAutoFile;
static const int VERSION = 200;
-static const char* pszSubVer = " rc2";
+static const char* pszSubVer = " test1";
@@ -194,28 +194,32 @@ uint64 ReadCompactSize(Stream& is) {
unsigned char chSize;
READDATA(is, chSize);
+ uint64 nSizeRet = 0;
if (chSize < UCHAR_MAX-2)
{
- return chSize;
+ nSizeRet = chSize;
}
else if (chSize == UCHAR_MAX-2)
{
unsigned short nSize;
READDATA(is, nSize);
- return nSize;
+ nSizeRet = nSize;
}
else if (chSize == UCHAR_MAX-1)
{
unsigned int nSize;
READDATA(is, nSize);
- return nSize;
+ nSizeRet = nSize;
}
else
{
uint64 nSize;
READDATA(is, nSize);
- return nSize;
+ nSizeRet = nSize;
}
+ if (nSizeRet > (uint64)INT_MAX)
+ throw std::ios_base::failure("ReadCompactSize() : size too large");
+ return nSizeRet;
}
@@ -460,7 +464,7 @@ void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion, unsigned int i = 0;
while (i < nSize)
{
- unsigned int blk = min(nSize - i, 1 + 4999999 / sizeof(T));
+ unsigned int blk = min(nSize - i, (unsigned int)(1 + 4999999 / sizeof(T)));
v.resize(i + blk);
is.read((char*)&v[i], blk * sizeof(T));
i += blk;
|