Skip to content

Commit

Permalink
depth protection for computesequencelength, retain/autorelease remove…
Browse files Browse the repository at this point in the history
…d for forked app

git-svn-id: https://svn.code.sf.net/p/osirix/code/osirix@7504 4e9e6e3d-4551-47eb-9dbe-a6127f9400a1
  • Loading branch information
rossetantoine committed Jul 27, 2010
1 parent 89abc77 commit 2a6725b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
10 changes: 6 additions & 4 deletions Binaries/dcmtk-source/dcmqrdb/dcmqrdbq.mm
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ void str_toupper(char *s)

// Search Core Data here
if( handle -> dataHandler == 0L)
handle -> dataHandler = [[OsiriXSCPDataHandler requestDataHandler] retain];
handle -> dataHandler = [OsiriXSCPDataHandler allocRequestDataHandler];

cond = [handle->dataHandler prepareFindForDataSet:findRequestIdentifiers];
MatchFound = [handle->dataHandler findMatchFound];
Expand Down Expand Up @@ -818,7 +818,7 @@ void str_toupper(char *s)
dbdebug(1, "nextFindResponse () : new dataset\n") ;

if( handle -> dataHandler == 0L)
handle -> dataHandler = [[OsiriXSCPDataHandler requestDataHandler] retain];
handle -> dataHandler = [OsiriXSCPDataHandler allocRequestDataHandler];

cond = [handle ->dataHandler nextFindObject:*findResponseIdentifiers isComplete:&isComplete];
dbdebug(1, "nextFindResponse () : next response\n") ;
Expand Down Expand Up @@ -880,7 +880,7 @@ void str_toupper(char *s)
status->setStatus(STATUS_Pending);
/**** Goto the next matching image number *****/
if( handle -> dataHandler == 0L)
handle -> dataHandler = [[OsiriXSCPDataHandler requestDataHandler] retain];
handle -> dataHandler = [OsiriXSCPDataHandler allocRequestDataHandler];

OFCondition cond = [handle->dataHandler nextMoveObject:imageFileName];
DcmFileFormat fileformat;
Expand Down Expand Up @@ -1069,7 +1069,7 @@ void str_toupper(char *s)
// Search Core Data here
//NSLog(@"search core data for move");
if( handle -> dataHandler == 0L)
handle -> dataHandler = [[OsiriXSCPDataHandler requestDataHandler] retain];
handle -> dataHandler = [OsiriXSCPDataHandler allocRequestDataHandler];

handle -> dataHandler.callingAET = [NSString stringWithUTF8String: handle -> callingAET];

Expand Down Expand Up @@ -1190,7 +1190,9 @@ void str_toupper(char *s)
DB_FreeElementList (handle -> findRequestList);
DB_FreeElementList (handle -> findResponseList);
DB_FreeUidList (handle -> uidList);

[handle -> dataHandler release];

free ( (char *) handle);
handle = nil;
}
Expand Down
2 changes: 1 addition & 1 deletion OsiriXSCPDataHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ typedef struct

@property (retain) NSString *callingAET;

+ (id)requestDataHandler;
+ (id)allocRequestDataHandler;

-(NSTimeInterval)endOfDay:(NSCalendarDate *)day;
-(NSTimeInterval)startOfDay:(NSCalendarDate *)day;
Expand Down
4 changes: 2 additions & 2 deletions OsiriXSCPDataHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ - (id)init
return self;
}

+ (id)requestDataHandler
+ (id)allocRequestDataHandler
{
return [[[OsiriXSCPDataHandler alloc] init] autorelease];
return [[OsiriXSCPDataHandler alloc] init];
}

//- (NSPredicate *)predicateForObject:(DCMObject *)object
Expand Down
17 changes: 15 additions & 2 deletions Papyrus3/PapyFiles3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1998,16 +1998,23 @@ ComputeUndefinedItemLength3 (PapyShort inFileNb, PapyULong *ioItemLengthP)
/* */
/********************************************************************************/

PapyShort
ComputeUndefinedSequenceLength3 (PapyShort inFileNb, PapyULong *ioSeqLengthP)
static volatile int ComputeUndefinedSequenceLength3DepthProtection = 0;

PapyShort ComputeUndefinedSequenceLength3 (PapyShort inFileNb, PapyULong *ioSeqLengthP)
{
PapyULong theElemLength, theBufPos, theFileStartPos, i;
PapyUShort theGrNb, theElemNb;
char theVR [3];
unsigned char *theBuffP, theBuff [8];
int OK, theErr = 0;

if( ComputeUndefinedSequenceLength3DepthProtection > 30)
{
printf("\r******* ComputeUndefinedSequenceLength3DepthProtection \r");
RETURN (papReadFile)
}

ComputeUndefinedSequenceLength3DepthProtection ++;
/* initialisation */
theGrNb = 0;
theElemNb = 0;
Expand All @@ -2026,6 +2033,7 @@ ComputeUndefinedSequenceLength3 (PapyShort inFileNb, PapyULong *ioSeqLengthP)
if (Papy3FRead (gPapyFile [inFileNb], &i, 1L, theBuffP) < 0)
{
Papy3FClose (&(gPapyFile [inFileNb]));
ComputeUndefinedSequenceLength3DepthProtection --;
RETURN (papReadFile)
} /* if */

Expand Down Expand Up @@ -2066,6 +2074,7 @@ ComputeUndefinedSequenceLength3 (PapyShort inFileNb, PapyULong *ioSeqLengthP)
if (Papy3FRead (gPapyFile [inFileNb], &i, 1L, theBuffP) < 0)
{
Papy3FClose (&(gPapyFile [inFileNb]));
ComputeUndefinedSequenceLength3DepthProtection --;
RETURN (papReadFile)
} /* if */
*ioSeqLengthP += 4L;
Expand All @@ -2084,7 +2093,10 @@ ComputeUndefinedSequenceLength3 (PapyShort inFileNb, PapyULong *ioSeqLengthP)
{
theElemLength = 0L;
if ((theErr = (int) ComputeUndefinedItemLength3 (inFileNb, &theElemLength)) < 0)
{
ComputeUndefinedSequenceLength3DepthProtection --;
RETURN (theErr);
}
} /* if */

*ioSeqLengthP += theElemLength;
Expand All @@ -2099,6 +2111,7 @@ ComputeUndefinedSequenceLength3 (PapyShort inFileNb, PapyULong *ioSeqLengthP)
/* reset the file pointer to its previous position */
Papy3FSeek (gPapyFile [inFileNb], (int) SEEK_SET, (PapyLong) theFileStartPos);

ComputeUndefinedSequenceLength3DepthProtection --;
return 0;

} /* endof ComputeUndefinedSequenceLength3 */
Expand Down
2 changes: 1 addition & 1 deletion QueryController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2509,7 +2509,7 @@ - (void) performRetrieve:(NSArray*) array
[previousAutoRetrieve removeObjectForKey: [self stringIDForStudy: object]];
}

[NSThread currentThread].progress = (float) i++ / (float) [moveArray count];
[NSThread currentThread].progress = (float) ++i / (float) [moveArray count];
if( [NSThread currentThread].isCancelled)
{
[[NSFileManager defaultManager] createFileAtPath: @"/tmp/kill_all_storescu" contents: [NSData data] attributes: nil];
Expand Down
2 changes: 1 addition & 1 deletion browserController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11140,7 +11140,7 @@ - (void) copyToDB: (NSDictionary*) d
if( [NSThread currentThread].isCancelled)
break;

[NSThread currentThread].progress = (float) t++ / (float) [[d objectForKey: @"packArray"] count];
[NSThread currentThread].progress = (float) ++t / (float) [[d objectForKey: @"packArray"] count];
[NSThread currentThread].status = [NSString stringWithFormat: NSLocalizedString( @"%d file(s)", nil), [[d objectForKey: @"packArray"] count]-t];
}

Expand Down

0 comments on commit 2a6725b

Please sign in to comment.