am 2d48d0ea: am c9358706: am 2e7b8d63: am f861bc5c: Merge "Don\'t search off the end of the index for bad Olson ids."

* commit '2d48d0ea36395da9af4537195483b006900bf7bd':
  Don't search off the end of the index for bad Olson ids.
This commit is contained in:
Elliott Hughes
2013-03-14 22:35:28 +00:00
committed by Android Git Automerger
3 changed files with 52 additions and 1 deletions

View File

@@ -2305,7 +2305,13 @@ static int __bionic_open_tzdata_path(const char* path, const char* olson_id, int
static const size_t NAME_LENGTH = 40;
unsigned char buf[NAME_LENGTH + 3 * sizeof(int32_t)];
while (TEMP_FAILURE_RETRY(read(fd, buf, sizeof(buf))) == (ssize_t) sizeof(buf)) {
size_t id_count = (ntohl(header.data_offset) - ntohl(header.index_offset)) / sizeof(buf);
for (size_t i = 0; i < id_count; ++i) {
if (TEMP_FAILURE_RETRY(read(fd, buf, sizeof(buf))) != (ssize_t) sizeof(buf)) {
break;
}
char this_id[NAME_LENGTH + 1];
memcpy(this_id, buf, NAME_LENGTH);
this_id[NAME_LENGTH] = '\0';