Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_secure_storage] Fix Crashes on Encrypting/Decrypting Empty Strings #715

Merged
merged 3 commits into from
Aug 9, 2024

Conversation

MAUstaoglu
Copy link
Contributor

Summary

This PR addresses an issue that caused the application to crash when attempting to encrypt or decrypt an empty string.

Changes

  • Encrypt Method:

    • Added a check to return a vector containing a single null byte when the input string is empty. This ensures that the function handles empty inputs without errors.
  • Decrypt Method:

    • Added a check to return an empty string when the input vector size is less than or equal to the initialization vector size. This prevents errors during decryption when the input is insufficient.

Testing

  • Verified that attempting to encrypt or decrypt an empty string no longer causes the application to crash.
  • To test with the example app, edit the value in the text field, remove all content to make it an empty string, and then save it. The application should handle this gracefully without crashing.

Notes

These changes improve the robustness of the encryption and decryption functions by ensuring they handle edge cases gracefully.

- Added a check in `Encrypt` to return a vector with a single null byte for empty strings to handle empty input gracefully.
- Added a check in `Decrypt` to return an empty string when the input size is less than or equal to the initialization vector size, preventing decryption errors.
Copy link
Member

@JSUYA JSUYA left a comment

Choose a reason for hiding this comment

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

The dart_analyze failed issue requires updates to these packages (battery_plus, flutter_webrtc, permission_handler, sensors_plus).

@JSUYA
Copy link
Member

JSUYA commented Aug 9, 2024

I tested it and checked it works fine.

@JSUYA JSUYA merged commit d9a0ddc into flutter-tizen:master Aug 9, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants