[Request] Handle empty status in OnlineUnlockStatus::load() to avoid assertion


#1

Many thanks to Jules for his recent work on the Tracktion Marketplace classes!
I was - once more - stunned about your reaction time (refactoring and fixing!) after I contacted you. Awesome!
 

I noticed one minor issue. Before an application has been unlocked, the assertion in

RSAKey::applyToValue (BigInteger& value)

gets hit.

That's because in OnlineUnlockStatus::load() an empty ValueTree named status will be created. This is used a few lines below:

data = KeyFileUtils::getDataFromKeyFile (KeyFileUtils::getXmlFromKeyFile (status[keyfileDataProp], getPublicKey()));

getXmlFromKeyFile apparently does not like an empty string as first argument.

 


#2

Thanks - should be OK now, let me know if you spot any other problems!


#3

This change just broke the unlocking.

A valid key file does not unlock an application anymore.

In String::fromUTF8()

jassert (CharPointer_UTF8::isValidString (buffer, bufferSizeBytes));

gets hit.
Afterwards unlocking fails.

Callstack:

#0    0x00000001001c3ea3 in juce::String::fromUTF8(char const*, int) at /Users/sam/data/docs/projects_dev/LUFSMeter/libraries/juce/modules/juce_core/text/juce_String.cpp:2116
#1    0x00000001001c3def in juce::MemoryBlock::toString() const at /Users/sam/data/docs/projects_dev/LUFSMeter/libraries/juce/modules/juce_core/memory/juce_MemoryBlock.cpp:273
#2    0x000000010054819d in juce::KeyFileUtils::decryptXML(juce::String, juce::RSAKey) at /Users/sam/data/docs/projects_dev/LUFSMeter/libraries/juce/modules/juce_tracktion_marketplace/marketplace/juce_OnlineUnlockStatus.cpp:77
#3    0x0000000100545dba in juce::KeyFileUtils::getXmlFromKeyFile(juce::String, juce::RSAKey) at /Users/sam/data/docs/projects_dev/LUFSMeter/libraries/juce/modules/juce_tracktion_marketplace/marketplace/juce_OnlineUnlockStatus.cpp:84
#4    0x000000010054219f in juce::OnlineUnlockStatus::applyKeyFile(juce::String) at /Users/sam/data/docs/projects_dev/LUFSMeter/libraries/juce/modules/juce_tracktion_marketplace/marketplace/juce_OnlineUnlockStatus.cpp:259


#4

Thanks.

Unlocking now works again.
But the issue from my first post also came back.


#5

Damn, stupid typo on my part! Thanks - try again!


#6

Hmm, the latest commit is still fcb87ee6.. from 2 hours ago. My post #4 already corresponds to that one.


#7

Agh! Having a bad day.. Ok, third time lucky! (I did actually test it this time!)


#8

OnlineUnlockStatus now works charmingly.

Thanks a lot!


#9

Guess this is minor. But since you've asked:
An attempt to unlock with an invalid key file raises an assertion.

#0    0x00000001001c46e3 in juce::String::fromUTF8(char const*, int) at /Users/sam/data/docs/projects_dev/LUFSMeter/libraries/juce/modules/juce_core/text/juce_String.cpp:2116
#1    0x00000001001c462f in juce::MemoryBlock::toString() const at /Users/sam/data/docs/projects_dev/LUFSMeter/libraries/juce/modules/juce_core/memory/juce_MemoryBlock.cpp:273
#2    0x0000000100548a44 in juce::KeyFileUtils::decryptXML(juce::String, juce::RSAKey) at /Users/sam/data/docs/projects_dev/LUFSMeter/libraries/juce/modules/juce_tracktion_marketplace/marketplace/juce_OnlineUnlockStatus.cpp:81
#3    0x00000001005465ba in juce::KeyFileUtils::getXmlFromKeyFile(juce::String, juce::RSAKey) at /Users/sam/data/docs/projects_dev/LUFSMeter/libraries/juce/modules/juce_tracktion_marketplace/marketplace/juce_OnlineUnlockStatus.cpp:89
#4    0x000000010054299f in juce::OnlineUnlockStatus::applyKeyFile(juce::String) at /Users/sam/data/docs/projects_dev/LUFSMeter/libraries/juce/modules/juce_tracktion_marketplace/marketplace/juce_OnlineUnlockStatus.cpp:264

 


#10

ok, ta. It's not a big deal as it won't make any difference in a release build, but I'll remove it when I get chance.