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

Probable Bug in OTA slot switch #2408

Closed
febeslmeisl opened this issue Aug 6, 2022 · 2 comments
Closed

Probable Bug in OTA slot switch #2408

febeslmeisl opened this issue Aug 6, 2022 · 2 comments

Comments

@febeslmeisl
Copy link

During further analysis of #2289 I encoutered following code in phh-ota.cpp:

		std::string current_slot;
		std::string next_slot;
		if(!android::base::ReadFileToString("/metadata/phh/img", &current_slot)) {
			next_slot = "a";
		} else {
			if(current_slot.c_str()[0] == 'a')
				next_slot = "b";
		}
		mkdir("/metadata/phh", 0700);
		android::base::WriteStringToFile(next_slot, "/metadata/phh/img");

Branch for having "b" in existing file /metadata/phh/img seems not covered in the if/elses and might write uninitialized "next_slot" to /metadata/phh/img. Code occures twice in

  • switch-slot
  • new-slot

(Upper part could also be refactored to a method like "getNextSlot" used in both sections)

phhusson added a commit to phhusson/device_phh_treble that referenced this issue Aug 24, 2022
@phhusson
Copy link
Owner

Uh yes, my code was very broken, thanks.

@febeslmeisl
Copy link
Author

febeslmeisl commented Aug 30, 2022

Thanks for fixing, but I thing branch "switch-slot", as already mentioned above is still affected, because it contained duplicate buggy code with "new-slot". I'm afraid slot switch from b back to a will not work at the moment. Since this is already closed, created #2424

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

No branches or pull requests

2 participants