Skip to content

Conversation

@fixxxedpoint
Copy link

Cardinal stopped loading my patches and instead was showing cleared (default template) versions. I was expecting that it was caused by the fact that I have updated Cardinal recently and somehow Ardour was complaining about new version of my vst3 plugins. It appeared that Cardinal was incorrectly identifying Rack v2 type of patches with the zstd magic sequence.

…ing the magic sequence of a zstd-compressed patch.
@falkTX
Copy link
Contributor

falkTX commented Nov 26, 2025

This is not really an off by one error, but potential misuse of sizeof(zstdMagic) which will return 5 here instead of the maybe expected 4.
The fix should not be to manually try to force things, but just changing char type to uint8_t for which the compiler does not try to be smart and assume data to be a null-terminated string.
Basically:

    static constexpr const uint8_t zstdMagic[] = {0x28, 0xb5, 0x2f, 0xfd};

@fixxxedpoint
Copy link
Author

This is not really an off by one error, but potential misuse of sizeof(zstdMagic) which will return 5 here instead of the maybe expected 4. The fix should not be to manually try to force things, but just changing char type to uint8_t for which the compiler does not try to be smart and assume data to be a null-terminated string. Basically:

    static constexpr const uint8_t zstdMagic[] = {0x28, 0xb5, 0x2f, 0xfd};

Good point. Changed it. In general that file could use some refactor or at least we could limit the number of those #if CARDINAL_VARIANT_MINI || !defined(HEADLESS).

@fixxxedpoint fixxxedpoint changed the title FIX: off-by-one error when identifying the patch/Rack version by reading the magic sequence of a zstd-compressed patch FIX: off-by-one error when identifying patch/Rack version by reading the magic sequence of a zstd-compressed patch Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants