libbootloader_message: host_supported.

Also, strlcat is not available on host, so use
std::string::operator+= instead.

Test: cuttlefish
Bug: 79094284

Change-Id: I1e69daeb522ca73f43e0c4855cf099a021ed4d47
This commit is contained in:
Yifan Hong
2019-05-01 13:12:57 -07:00
parent c784ce50e8
commit d83070ddb9
2 changed files with 26 additions and 4 deletions

View File

@@ -29,6 +29,10 @@
#include <android-base/unique_fd.h>
#include <fstab/fstab.h>
#ifndef __ANDROID__
#include <cutils/memory.h> // for strlcpy
#endif
using android::fs_mgr::Fstab;
using android::fs_mgr::ReadDefaultFstab;
@@ -194,13 +198,15 @@ bool update_bootloader_message_in_struct(bootloader_message* boot,
memset(boot->recovery, 0, sizeof(boot->recovery));
strlcpy(boot->command, "boot-recovery", sizeof(boot->command));
strlcpy(boot->recovery, "recovery\n", sizeof(boot->recovery));
std::string recovery = "recovery\n";
for (const auto& s : options) {
strlcat(boot->recovery, s.c_str(), sizeof(boot->recovery));
recovery += s;
if (s.back() != '\n') {
strlcat(boot->recovery, "\n", sizeof(boot->recovery));
recovery += '\n';
}
}
strlcpy(boot->recovery, recovery.c_str(), sizeof(boot->recovery));
return true;
}