rileytestut / AltServer-Windows

GNU Affero General Public License v3.0
141 stars 49 forks source link

ProvisioningProfile::ParseData function has a logic error. #10

Closed Amoystyle closed 7 months ago

Amoystyle commented 4 years ago

void ProvisioningProfile::ParseData(std::vector &encodedData)

   // entitlementsNode maybe null items
    plist_t bundleIdentifierNode = plist_dict_get_item(entitlementsNode, "application-identifier");
    if (bundleIdentifierNode == nullptr)
    {
        throw SignError(SignErrorCode::InvalidProvisioningProfile);
    }

    char *rawApplicationIdentifier = nullptr;
    plist_get_string_val(bundleIdentifierNode, &rawApplicationIdentifier);

    std::string applicationIdentifier(rawApplicationIdentifier);

    size_t location = applicationIdentifier.find(".");
    if (location == std::string::npos)
    {
        throw SignError(SignErrorCode::InvalidProvisioningProfile);
    }

    std::string bundleIdentifier(applicationIdentifier.begin() + location + 1, applicationIdentifier.end());

just do it

    // entitlementsNode maybe null items
    std::string bundleIdentifier;
    plist_t bundleIdentifierNode = plist_dict_get_item(entitlementsNode, "application-identifier");
    if (bundleIdentifierNode) {
        char *rawApplicationIdentifier = nullptr;
        plist_get_string_val(bundleIdentifierNode, &rawApplicationIdentifier);

        std::string applicationIdentifier(rawApplicationIdentifier);

        size_t location = applicationIdentifier.find(".");
        if (location == std::string::npos) {
            throw SignError(SignErrorCode::InvalidProvisioningProfile);
        }

        bundleIdentifier = applicationIdentifier.substr(location + 1);
    }
    else { // form Name "iOS Team Provisioning Profile: com.xxx.xxx.xxx"

        std::string applicationIdentifier(name);
        size_t location = applicationIdentifier.find("iOS Team Provisioning Profile: ");
        if (location == std::string::npos) {
            throw SignError(SignErrorCode::InvalidProvisioningProfile);
        }

        bundleIdentifier = applicationIdentifier.substr(strlen("iOS Team Provisioning Profile: "));
    }