Merge "fs_mgr: trim the terminating '\0' when reading from device tree" am: b76158d56a am: 3205cd6cc4 am: 776c67b4d5

am: ec721bdda2

Change-Id: I229b411a591b04de4bb557b1bc5b604d9a2e63d0
This commit is contained in:
Bowgo Tsai 2017-07-14 05:32:33 +00:00 committed by android-build-merger
commit dc43b54d33

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <string>
#include <android-base/file.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
@ -51,9 +53,11 @@ bool fs_mgr_get_boot_config(const std::string& key, std::string* out_val) {
// lastly, check the device tree
if (is_dt_compatible()) {
std::string file_name = kAndroidDtDir + "/" + key;
// DT entries terminate with '\0' but so do the properties
if (android::base::ReadFileToString(file_name, out_val)) {
return true;
if (!out_val->empty()) {
out_val->pop_back(); // Trims the trailing '\0' out.
return true;
}
}
}