From 233d279560dea496d9492daeeba947e101a79525 Mon Sep 17 00:00:00 2001 From: CaS Date: Thu, 30 Jun 2005 07:44:45 +0000 Subject: [PATCH] Fix to prevent crash (raise exception instead) when deserializing a corrupt file git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21379 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Source/NSSerializer.m | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6100a35f9..f731ade46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-06-30 Richard Frith-Macdonald + + * Source/NSSerializer.m: deserializeFromInfo() check that cross + reference indices are valid and raise an exception if not ... should + fix bug reported by Roland Schwingel, where trying to deserialize a + corrupt file could cause a crash. + 2005-06-28 Adam Fedor * Source/NSInvocation.m (-getReturnValue:, -setReturnValue:): Only diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index 9ac99a6af..5d776d523 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -520,7 +520,9 @@ static void endDeserializerInfo(_NSDeserializerInfo* info) { if (info->didUnique) - GSIArrayEmpty(&info->array); + { + GSIArrayEmpty(&info->array); + } } static id @@ -536,7 +538,15 @@ deserializeFromInfo(_NSDeserializerInfo* info) case ST_XREF: { size = (*info->deiImp)(info->data, deiSel, info->cursor); - return RETAIN(GSIArrayItemAtIndex(&info->array, size).obj); + if (size < GSIArrayCount(&info->array)) + { + return RETAIN(GSIArrayItemAtIndex(&info->array, size).obj); + } + else + { + [NSException raise: NSInvalidArgumentException + format: @"Bad cross reference in property list"]; + } } case ST_CSTRING: