~ubuntu-branches/ubuntu/precise/unrar-nonfree/precise-security

« back to all changes in this revision

Viewing changes to pathfn.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Meredith
  • Date: 2008-10-17 13:31:48 UTC
  • mfrom: (1.1.9 upstream) (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20081017133148-gey9fz11lui8oy79
Tags: 1:3.8.4-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
420
420
#endif
421
421
 
422
422
 
423
 
// returns a pointer to rightmost digit of volume number
 
423
// Returns a pointer to rightmost digit of volume number.
424
424
char* GetVolNumPart(char *ArcName)
425
425
{
 
426
  // Pointing to last name character.
426
427
  char *ChPtr=ArcName+strlen(ArcName)-1;
 
428
 
 
429
  // Skipping the archive extension.
427
430
  while (!isdigit(*ChPtr) && ChPtr>ArcName)
428
431
    ChPtr--;
 
432
 
 
433
  // Skipping the numeric part of name.
429
434
  char *NumPtr=ChPtr;
430
435
  while (isdigit(*NumPtr) && NumPtr>ArcName)
431
436
    NumPtr--;
 
437
 
 
438
  // Searching for first numeric part in names like name.part##of##.rar.
 
439
  // Stop search on the first dot.
432
440
  while (NumPtr>ArcName && *NumPtr!='.')
433
441
  {
434
442
    if (isdigit(*NumPtr))
435
443
    {
 
444
      // Validate the first numeric part only if it has a dot somwhere 
 
445
      // before it.
436
446
      char *Dot=strchrd(PointToName(ArcName),'.');
437
447
      if (Dot!=NULL && Dot<NumPtr)
438
448
        ChPtr=NumPtr;
507
517
 
508
518
    int CharsToCopy=strlen(ArcName)-(NumPtr-ArcName);
509
519
    int DestPos=strlenw(ArcNameW)-CharsToCopy;
510
 
    if (DestPos>0)
 
520
    if (DestPos>=0)
511
521
    {
512
522
      CharToWide(NumPtr,ArcNameW+DestPos,MaxLength-DestPos-1);
513
523
      ArcNameW[MaxLength-1]=0;