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

Crash when path is missing #285

Closed
vollkorn1982 opened this issue Jan 8, 2023 · 4 comments · Fixed by #290
Closed

Crash when path is missing #285

vollkorn1982 opened this issue Jan 8, 2023 · 4 comments · Fixed by #290
Milestone

Comments

@vollkorn1982
Copy link

I received the FreeOTP app 2.0 through F-Droid. It imported my entries without error, but when I open the app and simply scroll down in the list, it crashes.

This is the output on adb logcat:

01-08 15:55:28.186 19352 19352 I Adapter : Bind to view token [xxx][xxx]
01-08 15:55:28.197 19352 19352 E ahosted.freeotp: Invalid ID 0x00000000.
01-08 15:55:28.197 19352 19352 I Adapter : Bind to view token [xxx][xxx]
01-08 15:55:28.207  2076 15697 D CompatibilityChangeReporter: Compat change id reported: 161145287; UID 10165; state: DISABLED
01-08 15:55:28.208 19352 19352 D AndroidRuntime: Shutting down VM
01-08 15:55:28.208 19352 19352 E AndroidRuntime: FATAL EXCEPTION: main
01-08 15:55:28.208 19352 19352 E AndroidRuntime: Process: org.fedorahosted.freeotp, PID: 19352
01-08 15:55:28.208 19352 19352 E AndroidRuntime: java.lang.IllegalArgumentException: Path must not be empty.
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at com.squareup.picasso.Picasso.load(Picasso.java:332)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at org.fedorahosted.freeotp.main.ViewHolder.bind(ViewHolder.java:255)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at org.fedorahosted.freeotp.main.Adapter.onBindViewHolder(Adapter.java:172)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at org.fedorahosted.freeotp.main.Adapter.onBindViewHolder(Adapter.java:64)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7065)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at androidx.recyclerview.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:288)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at androidx.recyclerview.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:345)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at androidx.recyclerview.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:361)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at androidx.recyclerview.widget.GapWorker.prefetch(GapWorker.java:368)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at androidx.recyclerview.widget.GapWorker.run(GapWorker.java:399)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:942)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:201)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:288)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7872)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
01-08 15:55:28.208 19352 19352 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
01-08 15:55:28.210  2076 19392 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
01-08 15:55:28.211  2076 15697 W ActivityTaskManager:   Force finishing activity org.fedorahosted.freeotp/.main.Activity
01-08 15:55:28.215  2076  3822 E FrameEvents: updateAcquireFence: Did not find frame.
01-08 15:55:28.219  2076  2206 I ActivityManager: Showing crash dialog for package org.fedorahosted.freeotp u0

I assume the path was optional with FreeOTP < 2.0 and the importer did not check for this requirement.

@vollkorn1982
Copy link
Author

I checked the source a bit and found out that this happens if you have set an empty image path. I have no clue how it got in there, but (HTML-decoded) my /data/data/org.fedorahosted.freeotp/shared_prefs/tokenStore.xml looked like this:

[...]
    <string name="xxx">{"algo":"SHA1","counter":0,"digits":6,"image":"","issuerExt":"xxx","issuerInt":"xxx","label":"xxx","period":30,"type":"TOTP"}</string>
[...]

I removed the "image":"" and then the app stopped crashing.

Since I suspect this to be a problem of the importer, it probably is b0rken for a couple users who cannot recover from this because they havo no root on their devices and cannot edit the shared_prefs. Therefore, I suggest to gracefully handle empty, but none null image paths in the Token class or before passing them to picasso.

@vollkorn1982
Copy link
Author

Oh, I just realized there is a way to fix this for some users by using the backup method.

  1. Tap the kebab menu button on the top right.
  2. Select "Backup".
  3. Choose a filename. It will be amended with ".xml".
  4. Edit that file and remove any "image":"",.
  5. Restore from this backup.

This only works, though, if the app loads at least the first page of entries without crashing.

@justin-stephenson
Copy link
Contributor

Thank you for reporting this issue, and providing the logs. This is an important fix to address the image URI parameter requirement.

@justin-stephenson justin-stephenson added this to the v2.1.0 milestone Jan 9, 2023
@justin-stephenson
Copy link
Contributor

The problem here is that "image":"" is null, where it normally points to an image path. I'm not sure how this happened but FreeOTP should handle this gracefully and prevent crashing.

justin-stephenson added a commit to justin-stephenson/freeotp-android that referenced this issue Jan 9, 2023
justin-stephenson added a commit to justin-stephenson/freeotp-android that referenced this issue Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants