Skip to content

fix(module/config): read postgres byte streams before decryption#1772

Open
affinitytechworks wants to merge 2 commits intocypht-org:masterfrom
affinitytechworks:fix-postgres-blob
Open

fix(module/config): read postgres byte streams before decryption#1772
affinitytechworks wants to merge 2 commits intocypht-org:masterfrom
affinitytechworks:fix-postgres-blob

Conversation

@affinitytechworks
Copy link

PostgreSQL can hand hm_user_settings.settings back as a stream resource when PDO is built with libpq support. Passing that resource straight into base64_decode() causes a PHP 8 fatal error before libsodium gets a chance to decrypt the payload. Normalizing the value with stream_get_contents() ensures the stored settings are always a string before decode/decrypt, which allows users to log in again.

if (!$this->crypt) {
$data = $this->decode($data['settings']);
$settings = $data['settings'];
if (is_resource($settings)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this at the place where stream is defined/used? It seems awkward to work with streams here. THis method should receive a string.

}
else {
$this->tls = false;
$this->tls = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be part of another PR (which I already merged). Can you push one change at a time to a PR? Thanks.

@marclaporte
Copy link
Member

@affinitytechworks We need you :-)

@IrAlfred
Copy link
Member

IrAlfred commented Nov 28, 2025

Seems related to #1790

@marclaporte
Copy link
Member

@affinitytechworks we need you :-)

@affinitytechworks
Copy link
Author

affinitytechworks commented Jan 14, 2026 via email

@marclaporte
Copy link
Member

No problem. Please just come back when you can :-)

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.

4 participants