Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 155949
Collapse All | Expand All

(-)file_not_specified_in_diff (-17 / +24 lines)
Line  Link Here
0
-- kfile-plugins/jpeg/exif.h
0
++ kfile-plugins/jpeg/exif.h
Lines 72-78 Link Here
72
    int Get32s(void * Long);
72
    int Get32s(void * Long);
73
    unsigned Get32u(void * Long);
73
    unsigned Get32u(void * Long);
74
    double ConvertAnyFormat(void * ValuePtr, int Format);
74
    double ConvertAnyFormat(void * ValuePtr, int Format);
75
    void ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength);
75
    void ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength,
76
            unsigned NestingLevel);
76
    void process_COM (const uchar * Data, int length);
77
    void process_COM (const uchar * Data, int length);
77
    void process_SOFn (const uchar * Data, int marker);
78
    void process_SOFn (const uchar * Data, int marker);
78
    int Get16m(const void * Short);
79
    int Get16m(const void * Short);
79
-- kfile-plugins/jpeg/exif.cpp
80
++ kfile-plugins/jpeg/exif.cpp
Lines 446-452 Link Here
446
//--------------------------------------------------------------------------
446
//--------------------------------------------------------------------------
447
// Process one of the nested EXIF directories.
447
// Process one of the nested EXIF directories.
448
//--------------------------------------------------------------------------
448
//--------------------------------------------------------------------------
449
void ExifData::ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength)
449
void ExifData::ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength, unsigned NestingLevel)
450
{
450
{
451
    int de;
451
    int de;
452
    int a;
452
    int a;
Lines 454-459 Link Here
454
    unsigned ThumbnailOffset = 0;
454
    unsigned ThumbnailOffset = 0;
455
    unsigned ThumbnailSize = 0;
455
    unsigned ThumbnailSize = 0;
456
456
457
    if ( NestingLevel > 4)
458
        throw FatalError("Maximum directory nesting exceeded (corrupt exif header)");
459
457
    NumDirEntries = Get16u(DirStart);
460
    NumDirEntries = Get16u(DirStart);
458
    #define DIR_ENTRY_ADDR(Start, Entry) (Start+2+12*(Entry))
461
    #define DIR_ENTRY_ADDR(Start, Entry) (Start+2+12*(Entry))
459
462
Lines 476-482 Link Here
476
    for (de=0;de<NumDirEntries;de++){
479
    for (de=0;de<NumDirEntries;de++){
477
        int Tag, Format, Components;
480
        int Tag, Format, Components;
478
        unsigned char * ValuePtr;
481
        unsigned char * ValuePtr;
479
        int ByteCount;
482
        unsigned ByteCount;
480
        char * DirEntry;
483
        char * DirEntry;
481
        DirEntry = (char *)DIR_ENTRY_ADDR(DirStart, de);
484
        DirEntry = (char *)DIR_ENTRY_ADDR(DirStart, de);
482
485
Lines 489-494 Link Here
489
            throw FatalError("Illegal format code in EXIF dir");
492
            throw FatalError("Illegal format code in EXIF dir");
490
        }
493
        }
491
494
495
        if ((unsigned)Components > 0x10000) {
496
            throw FatalError("Illegal number of components for tag");
497
            continue;
498
        }
499
492
        ByteCount = Components * BytesPerFormat[Format];
500
        ByteCount = Components * BytesPerFormat[Format];
493
501
494
        if (ByteCount > 4){
502
        if (ByteCount > 4){
Lines 517-527 Link Here
517
        switch(Tag){
525
        switch(Tag){
518
526
519
            case TAG_MAKE:
527
            case TAG_MAKE:
520
                ExifData::CameraMake = QString((char*)ValuePtr);
528
                ExifData::CameraMake = QString::fromLatin1((const char*)ValuePtr, 31);
521
                break;
529
                break;
522
530
523
            case TAG_MODEL:
531
            case TAG_MODEL:
524
                ExifData::CameraModel = QString((char*)ValuePtr);
532
                ExifData::CameraModel = QString::fromLatin1((const char*)ValuePtr, 39);
525
		break;
533
		break;
526
534
527
            case TAG_ORIENTATION:
535
            case TAG_ORIENTATION:
Lines 529-535 Link Here
529
                break;
537
                break;
530
538
531
            case TAG_DATETIME_ORIGINAL:
539
            case TAG_DATETIME_ORIGINAL:
532
		DateTime = QString((char*)ValuePtr);
540
		DateTime = QString::fromLatin1((const char*)ValuePtr, 19);
533
                break;
541
                break;
534
542
535
            case TAG_USERCOMMENT:
543
            case TAG_USERCOMMENT:
Lines 550-563 Link Here
550
                        int c;
558
                        int c;
551
                        c = (ValuePtr)[a];
559
                        c = (ValuePtr)[a];
552
                        if (c != '\0' && c != ' '){
560
                        if (c != '\0' && c != ' '){
553
                            //strncpy(ImageInfo.Comments, (const char*)(a+ValuePtr), 199);
561
                            UserComment = QString::fromLatin1((const char*)(a+ValuePtr), 199);
554
                            UserComment.sprintf("%s", (const char*)(a+ValuePtr));
555
                            break;
562
                            break;
556
                        }
563
                        }
557
                    }
564
                    }
558
                }else{
565
                }else{
559
                    //strncpy(ImageInfo.Comments, (const char*)ValuePtr, 199);
566
                    UserComment = QString::fromLatin1((const char*)ValuePtr, 199);
560
                    UserComment.sprintf("%s", (const char*)ValuePtr);
561
                }
567
                }
562
                break;
568
                break;
563
569
Lines 676-685 Link Here
676
        if (Tag == TAG_EXIF_OFFSET || Tag == TAG_INTEROP_OFFSET){
682
        if (Tag == TAG_EXIF_OFFSET || Tag == TAG_INTEROP_OFFSET){
677
            unsigned char * SubdirStart;
683
            unsigned char * SubdirStart;
678
            SubdirStart = OffsetBase + Get32u(ValuePtr);
684
            SubdirStart = OffsetBase + Get32u(ValuePtr);
679
            if (SubdirStart < OffsetBase || SubdirStart > OffsetBase+ExifLength){
685
            if (SubdirStart <= OffsetBase || SubdirStart >= OffsetBase+ExifLength){
680
                throw FatalError("Illegal subdirectory link");
686
                throw FatalError("Illegal subdirectory link");
681
            }
687
            }
682
            ProcessExifDir(SubdirStart, OffsetBase, ExifLength);
688
            ProcessExifDir(SubdirStart, OffsetBase, ExifLength, NestingLevel+1);
683
            continue;
689
            continue;
684
        }
690
        }
685
    }
691
    }
Lines 709-715 Link Here
709
                    }
715
                    }
710
                }else{
716
                }else{
711
                    if (SubdirStart <= OffsetBase+ExifLength){
717
                    if (SubdirStart <= OffsetBase+ExifLength){
712
                        ProcessExifDir(SubdirStart, OffsetBase, ExifLength);
718
                        ProcessExifDir(SubdirStart, OffsetBase, ExifLength, NestingLevel+1);
713
                    }
719
                    }
714
                }
720
                }
715
            }
721
            }
Lines 719-725 Link Here
719
    }
725
    }
720
726
721
    if (ThumbnailSize && ThumbnailOffset){
727
    if (ThumbnailSize && ThumbnailOffset){
722
        if (ThumbnailSize + ThumbnailOffset <= ExifLength){
728
        if (ThumbnailSize + ThumbnailOffset < ExifLength){
723
            // The thumbnail pointer appears to be valid.  Store it.
729
            // The thumbnail pointer appears to be valid.  Store it.
724
	    Thumbnail.loadFromData(OffsetBase + ThumbnailOffset, ThumbnailSize, "JPEG");
730
	    Thumbnail.loadFromData(OffsetBase + ThumbnailOffset, ThumbnailSize, "JPEG");
725
        }
731
        }
Lines 810-816 Link Here
810
    LastExifRefd = CharBuf;
816
    LastExifRefd = CharBuf;
811
817
812
    // First directory starts 16 bytes in.  Offsets start at 8 bytes in.
818
    // First directory starts 16 bytes in.  Offsets start at 8 bytes in.
813
    ProcessExifDir(CharBuf+16, CharBuf+8, length-6);
819
    ProcessExifDir(CharBuf+16, CharBuf+8, length-6, 0);
814
820
815
    // This is how far the interesting (non thumbnail) part of the exif went.
821
    // This is how far the interesting (non thumbnail) part of the exif went.
816
    ExifSettingsLength = LastExifRefd - CharBuf;
822
    ExifSettingsLength = LastExifRefd - CharBuf;

Return to bug 155949