HISE icon indicating copy to clipboard operation
HISE copied to clipboard

checkExpirationData() could return value years in the future

Open dustbro opened this issue 9 months ago • 0 comments

Corrupt or unexpected data entered in the checkExpirationData() could unlock the app. For example, running ul.checkExpirationData("poop") will return return var("encodedTimeString data is corrupt"); value for checkExpirationData() which unlocks a demo and creates an expiration date years in the future.

Possible solution: Returning a value of 0 may keep the app from accidentally unlocking.

juce::var ScriptUnlocker::RefObject::checkExpirationData(const String& encodedTimeString)
{
	if (unlocker != nullptr)
	{
		if (encodedTimeString.startsWith("0x"))
		{
			BigInteger bi;

			bi.parseString(encodedTimeString.substring(2), 16);
			unlocker->getPublicKey().applyToValue(bi);

			auto timeString = bi.toMemoryBlock().toString();

			auto time = Time::fromISO8601(timeString);

			auto ok = unlocker->unlockWithTime(time);

			auto delta = unlocker->getExpiryTime() - time;

			if (ok)
			{
#if USE_FRONTEND
				dynamic_cast<FrontendProcessor*>(getScriptProcessor()->getMainController_())->loadSamplesAfterRegistration(true);
#endif

				return var(roundToInt(delta.inDays()));
			}
			else
			{
				return var(false);
		}
	}
		else
		{
			// When the encodedTimeString data is corrupt or not as expected.
			return var(false); // or whatever value indicates "not unlocked"
		}
}
	else
	{
		return var("No unlocker");
	}
}

dustbro avatar Sep 25 '23 17:09 dustbro