Skip to content

Fix Uninitialized String offset error in validUtf8()#4

Closed
pravussum wants to merge 1 commit intohorde:masterfrom
pravussum:fix-uninitialized-string-offset
Closed

Fix Uninitialized String offset error in validUtf8()#4
pravussum wants to merge 1 commit intohorde:masterfrom
pravussum:fix-uninitialized-string-offset

Conversation

@pravussum
Copy link
Copy Markdown
Contributor

No description provided.

@yunosh
Copy link
Copy Markdown
Member

yunosh commented Jan 12, 2022

When does this happen? Do you have a test case?

@pravussum
Copy link
Copy Markdown
Contributor Author

pravussum commented Jan 12, 2022

I made this change in reaction to a crash in Nextcloud Mail (using the Horde libraries under the hood) where the stack trace revealed this very line. I think its an edge case (It was a spam mail being processed).
After fixing it in-place, the crash didn't happen anymore, but I'm afraid I deleted the spam message.

@pravussum
Copy link
Copy Markdown
Contributor Author

I have a backtrace now:

"file":"/var/www/html/custom_apps/mail/vendor/pear-pear.horde.org/Horde_Util/Horde/String.php","line":873,"function":"onAll","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"Uninitialized string offset 14","/var/www/html/custom_apps/mail/vendor/pear-pear.horde.org/Horde_Util/Horde/String.php",873]
"file":"/var/www/html/custom_apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Headers/Element.php","line":126,"function":"validUtf8","class":"Horde_String","type":"::","args":[null]
"file":"/var/www/html/custom_apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Headers/Addresses.php","line":86,"function":"_sanityCheck","class":"Horde_Mime_Headers_Element","type":"->","args":[null]
"file":"/var/www/html/custom_apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Headers/Element.php","line":79,"function":"_setValue","class":"Horde_Mime_Headers_Addresses","type":"->","args":[null]
"file":"/var/www/html/custom_apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Headers/Element.php","line":56,"function":"setValue","class":"Horde_Mime_Headers_Element","type":"->","args":[null]
"file":"/var/www/html/custom_apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Headers.php","line":201,"function":"__construct","class":"Horde_Mime_Headers_Element","type":"->","args":["Cc",null]
"file":"/var/www/html/custom_apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Headers.php","line":371,"function":"addHeader","class":"Horde_Mime_Headers","type":"->","args":["Cc",null]
"file":"/var/www/html/custom_apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Data/Fetch.php","line":628,"function":"parseHeaders","class":"Horde_Mime_Headers","type":"::","args":[{"__class__":"Horde_Stream_Temp","stream":null}]
"file":"/var/www/html/custom_apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Data/Fetch.php","line":157,"function":"_getHeaders","class":"Horde_Imap_Client_Data_Fetch","type":"->","args":["0",1,3]

ChristophWurst added a commit to ChristophWurst/Horde_Util that referenced this pull request May 25, 2022
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
ralflang added a commit that referenced this pull request Mar 16, 2026
Port PR #4 from pravussum to both lib/ and src/ versions.

Fixes "Uninitialized string offset" error when validUtf8() processes
truncated UTF-8 multi-byte sequences at the end of a string.

Co-authored-by: pravussum <pravussum@users.noreply.github.com>
ralflang added a commit that referenced this pull request Mar 16, 2026
Port PR #4 from pravussum to both lib/ and src/ versions.

Fixes "Uninitialized string offset" error when validUtf8() processes
truncated UTF-8 multi-byte sequences at the end of a string.

Co-authored-by: pravussum <pravussum@users.noreply.github.com>
@ralflang ralflang closed this in #21 Mar 16, 2026
@ralflang
Copy link
Copy Markdown
Member

Thank you for reporting

ralflang added a commit that referenced this pull request Mar 16, 2026
Add test cases for truncated UTF-8 sequences in validUtf8()
Validates PR #4 fix for out-of-bounds access and some edge cases
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.

3 participants