Skip to content
New issue

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

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

Already on GitHub? # to your account

Prevent communication usage after closing #380

Merged
merged 2 commits into from
Mar 11, 2023
Merged

Conversation

depau
Copy link
Collaborator

@depau depau commented Mar 10, 2023

This is more of a workaround for poor coding in EtchDroid but I think it would be helpful to everyone anyway.

Since I'm now uglily doing asynchronous I/O (sort of) it sometimes happens that I throw an exception while performing an operation, close the device in the finally block, but meanwhile the I/O thread finishes up a .read() on the block device while closed causing a use-after-free inside libusb.

This clearly isn't great user experience.

These changes ensure that the device isn't closed before any communication is performed, throwing an IllegalStateException if that's not the case. It still crashes but the user experience is better than SIGSEGV :)

@magnusja magnusja merged commit 41ebafd into develop Mar 11, 2023
@magnusja magnusja deleted the feature/avoid-segfault branch March 11, 2023 10:55
@magnusja
Copy link
Owner

Thanks a lot!

WIll release a new version. Also there is GPT support now, although probably not very interesting for you :D

@depau
Copy link
Collaborator Author

depau commented Mar 11, 2023

I decided to ditch all features that aren't strictly "verbatim byte copy to block device" since as you may have noticed I haven't had lots of fun maintaining it over the last 3 years or so, so not really interesing for my use cases :)

It's good to hear though! I was reading you also support FAT16 now and that sounds cool considering I might get around to add support for the USB floppy protocol at some point. It'll be very fun to write Plop Boot Manager using an Android phone :)

@magnusja
Copy link
Owner

FAT16 is not really supported. Only with java-fs but yeah, that is a little experimental Id say :D

But if needed I think it can be implemented on top of FAT32 fairly easily. Another option would be https://github.com/waldheinz/fat32-lib

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants