~libqtelegram-team/telegram-app/dev-secret-media-nosave

« back to all changes in this revision

Viewing changes to lib/telegram.cpp

prevent writing myKey or sharedKey to settings when they're pointed by a null pointer

Show diffs side-by-side

added added

removed removed

Lines of Context:
628
628
    DecryptedMessage decrypted = mDecrypter.decryptEncryptedData(encrypted.randomId(), encrypted.bytes());
629
629
    secretChatMessage.setDecryptedMessage(decrypted);
630
630
 
631
 
    EncryptedFile attachment = encrypted.file();
632
631
    // if having a not 0 randomId, the decrypted message is valid
633
632
    if (decrypted.randomId()) {
 
633
 
 
634
        EncryptedFile attachment = encrypted.file();
 
635
 
634
636
        //if attachment, check keyFingerprint
635
637
        if (attachment.classType() != EncryptedFile::typeEncryptedFileEmpty) {
 
638
 
636
639
            qint32 receivedKeyFingerprint = attachment.keyFingerprint();
637
640
            const QByteArray &key = decrypted.media().key();
638
641
            const QByteArray &iv = decrypted.media().iv();
648
651
 
649
652
            secretChatMessage.setAttachment(attachment);
650
653
        }
 
654
 
 
655
        mSecretState.save();
651
656
    }
652
657
 
653
 
    mSecretState.save();
654
 
 
655
658
    return secretChatMessage;
656
659
}
657
660
 
661
664
        EncryptedMessage encrypted = update.encryptedMessage();
662
665
 
663
666
        SecretChatMessage secretChatMessage = toSecretChatMessage(encrypted);
 
667
 
664
668
        // if having a not 0 randomId, the decrypted message is valid
665
669
        if (secretChatMessage.decryptedMessage().randomId()) {
666
670
            mSecretState.save();