diff options
author | Tianjie Xu <xunchang@google.com> | 2019-04-23 19:31:23 +0200 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-04-23 19:31:23 +0200 |
commit | 72e6e55e3403811acdf0207b8768de9c759354e3 (patch) | |
tree | 5744c05239aeab605fcc91215f8dced8f0b8bb6a /minui | |
parent | Merge "minadbd: Support rescue install and getprop commands." (diff) | |
parent | matches_locale no longer accept empty locales in the png file (diff) | |
download | android_bootable_recovery-72e6e55e3403811acdf0207b8768de9c759354e3.tar android_bootable_recovery-72e6e55e3403811acdf0207b8768de9c759354e3.tar.gz android_bootable_recovery-72e6e55e3403811acdf0207b8768de9c759354e3.tar.bz2 android_bootable_recovery-72e6e55e3403811acdf0207b8768de9c759354e3.tar.lz android_bootable_recovery-72e6e55e3403811acdf0207b8768de9c759354e3.tar.xz android_bootable_recovery-72e6e55e3403811acdf0207b8768de9c759354e3.tar.zst android_bootable_recovery-72e6e55e3403811acdf0207b8768de9c759354e3.zip |
Diffstat (limited to 'minui')
-rw-r--r-- | minui/resources.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/minui/resources.cpp b/minui/resources.cpp index 069a49529..00d36d5fb 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp @@ -347,6 +347,10 @@ bool matches_locale(const std::string& prefix, const std::string& locale) { // match the locale string without the {script} section. // For instance, prefix == "en" matches locale == "en-US", prefix == "sr-Latn" matches locale // == "sr-Latn-BA", and prefix == "zh-CN" matches locale == "zh-Hans-CN". + if (prefix.empty()) { + return false; + } + if (android::base::StartsWith(locale, prefix)) { return true; } @@ -414,12 +418,18 @@ int res_create_localized_alpha_surface(const char* name, __unused int len = row[4]; char* loc = reinterpret_cast<char*>(&row[5]); - if (y + 1 + h >= height || matches_locale(loc, locale)) { + // We need to include one additional line for the metadata of the localized image. + if (y + 1 + h > height) { + printf("Read exceeds the image boundary, y %u, h %d, height %u\n", y, h, height); + return -8; + } + + if (matches_locale(loc, locale)) { printf(" %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y); auto surface = GRSurface::Create(w, h, w, 1); if (!surface) { - return -8; + return -9; } for (int i = 0; i < h; ++i, ++y) { @@ -428,7 +438,7 @@ int res_create_localized_alpha_surface(const char* name, } *pSurface = surface.release(); - break; + return 0; } for (int i = 0; i < h; ++i, ++y) { @@ -436,7 +446,7 @@ int res_create_localized_alpha_surface(const char* name, } } - return 0; + return -10; } void res_free_surface(GRSurface* surface) { |