mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Fix for error decoding archives made on machine with different word size
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40208 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e0267770ef
commit
f5b4336181
3 changed files with 56 additions and 8 deletions
|
@ -1,3 +1,11 @@
|
|||
2016-11-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSPortCoder.m:
|
||||
* Source/NSUnarchiver.m:
|
||||
Fix for logic error decoding archives created by a machine with a
|
||||
different word size. Was checking the size of the encoded scalar
|
||||
item, but not against the *local* size of the same type.
|
||||
|
||||
2016-11-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSObject.m: Fix error in last mod ... was calculating opbject
|
||||
|
|
|
@ -578,6 +578,26 @@ static unsigned encodingVersion;
|
|||
return [_comp objectAtIndex: pos];
|
||||
}
|
||||
|
||||
static inline int
|
||||
scalarSize(char type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case _C_SHT:
|
||||
case _C_USHT: return _GSC_S_SHT;
|
||||
case _C_INT:
|
||||
case _C_UINT: return _GSC_S_INT;
|
||||
case _C_LNG:
|
||||
case _C_ULNG: return _GSC_S_LNG;
|
||||
case _C_LNG_LNG:
|
||||
case _C_ULNG_LNG: return _GSC_S_LNG_LNG;
|
||||
default:
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"scalarSize() called with non-scalar type"];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (void) decodeValueOfObjCType: (const char*)type
|
||||
at: (void*)address
|
||||
{
|
||||
|
@ -951,7 +971,7 @@ static unsigned encodingVersion;
|
|||
case _GSC_SHT:
|
||||
case _GSC_USHT:
|
||||
typeCheck(*type, info & _GSC_MASK);
|
||||
if ((info & _GSC_SIZE) == _GSC_S_SHT)
|
||||
if ((info & _GSC_SIZE) == scalarSize(*type))
|
||||
{
|
||||
(*_dDesImp)(_src, dDesSel, address, type, &_cursor, nil);
|
||||
return;
|
||||
|
@ -961,7 +981,7 @@ static unsigned encodingVersion;
|
|||
case _GSC_INT:
|
||||
case _GSC_UINT:
|
||||
typeCheck(*type, info & _GSC_MASK);
|
||||
if ((info & _GSC_SIZE) == _GSC_S_INT)
|
||||
if ((info & _GSC_SIZE) == scalarSize(*type))
|
||||
{
|
||||
(*_dDesImp)(_src, dDesSel, address, type, &_cursor, nil);
|
||||
return;
|
||||
|
@ -971,7 +991,7 @@ static unsigned encodingVersion;
|
|||
case _GSC_LNG:
|
||||
case _GSC_ULNG:
|
||||
typeCheck(*type, info & _GSC_MASK);
|
||||
if ((info & _GSC_SIZE) == _GSC_S_LNG)
|
||||
if ((info & _GSC_SIZE) == scalarSize(*type))
|
||||
{
|
||||
(*_dDesImp)(_src, dDesSel, address, type, &_cursor, nil);
|
||||
return;
|
||||
|
@ -982,7 +1002,7 @@ static unsigned encodingVersion;
|
|||
case _GSC_LNG_LNG:
|
||||
case _GSC_ULNG_LNG:
|
||||
typeCheck(*type, info & _GSC_MASK);
|
||||
if ((info & _GSC_SIZE) == _GSC_S_LNG_LNG)
|
||||
if ((info & _GSC_SIZE) == scalarSize(*type))
|
||||
{
|
||||
(*_dDesImp)(_src, dDesSel, address, type, &_cursor, nil);
|
||||
return;
|
||||
|
|
|
@ -837,6 +837,26 @@ static unsigned encodingVersion;
|
|||
}
|
||||
}
|
||||
|
||||
static inline int
|
||||
scalarSize(char type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case _C_SHT:
|
||||
case _C_USHT: return _GSC_S_SHT;
|
||||
case _C_INT:
|
||||
case _C_UINT: return _GSC_S_INT;
|
||||
case _C_LNG:
|
||||
case _C_ULNG: return _GSC_S_LNG;
|
||||
case _C_LNG_LNG:
|
||||
case _C_ULNG_LNG: return _GSC_S_LNG_LNG;
|
||||
default:
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"scalarSize() called with non-scalar type"];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (void) decodeValueOfObjCType: (const char*)type
|
||||
at: (void*)address
|
||||
{
|
||||
|
@ -1197,7 +1217,7 @@ static unsigned encodingVersion;
|
|||
case _GSC_SHT:
|
||||
case _GSC_USHT:
|
||||
if (YES == typeCheck(*type, info & _GSC_MASK)
|
||||
&& (info & _GSC_SIZE) == _GSC_S_SHT)
|
||||
&& (info & _GSC_SIZE) == scalarSize(*type))
|
||||
{
|
||||
(*desImp)(src, desSel, address, type, &cursor, nil);
|
||||
return;
|
||||
|
@ -1207,7 +1227,7 @@ static unsigned encodingVersion;
|
|||
case _GSC_INT:
|
||||
case _GSC_UINT:
|
||||
if (YES == typeCheck(*type, info & _GSC_MASK)
|
||||
&& (info & _GSC_SIZE) == _GSC_S_INT)
|
||||
&& (info & _GSC_SIZE) == scalarSize(*type))
|
||||
{
|
||||
(*desImp)(src, desSel, address, type, &cursor, nil);
|
||||
return;
|
||||
|
@ -1217,7 +1237,7 @@ static unsigned encodingVersion;
|
|||
case _GSC_LNG:
|
||||
case _GSC_ULNG:
|
||||
if (YES == typeCheck(*type, info & _GSC_MASK)
|
||||
&& (info & _GSC_SIZE) == _GSC_S_LNG)
|
||||
&& (info & _GSC_SIZE) == scalarSize(*type))
|
||||
{
|
||||
(*desImp)(src, desSel, address, type, &cursor, nil);
|
||||
return;
|
||||
|
@ -1227,7 +1247,7 @@ static unsigned encodingVersion;
|
|||
case _GSC_LNG_LNG:
|
||||
case _GSC_ULNG_LNG:
|
||||
if (YES == typeCheck(*type, info & _GSC_MASK)
|
||||
&& (info & _GSC_SIZE) == _GSC_S_LNG_LNG)
|
||||
&& (info & _GSC_SIZE) == scalarSize(*type))
|
||||
{
|
||||
(*desImp)(src, desSel, address, type, &cursor, nil);
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue