From 4fec8e9e9a97810294c2dabe0b169198f461cafb Mon Sep 17 00:00:00 2001 From: Abhishek Arpure Date: Thu, 24 Aug 2017 15:27:16 +0530 Subject: Integer overflow observed while formatting volume While calculating volume size, get_block_device_size() returns u64 value but the returned value is assigned in ssize_t variable. This may cause integer overflow if the volume size is beyond ssize_t limit. Use int64_t instead of ssize_t in get_file_size() and explicitly check for overflow to fix the issue. Bug: 65001754 Test: mmma bootable/recovery Change-Id: I91eb30bff0bf7dcc48678efc2f414d2b79af6d0d --- roots.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/roots.cpp b/roots.cpp index fdcbfe844..26602a710 100644 --- a/roots.cpp +++ b/roots.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -178,16 +179,22 @@ static int exec_cmd(const std::vector& args) { return WEXITSTATUS(status); } -static ssize_t get_file_size(int fd, uint64_t reserve_len) { +static int64_t get_file_size(int fd, uint64_t reserve_len) { struct stat buf; int ret = fstat(fd, &buf); if (ret) return 0; - ssize_t computed_size; + int64_t computed_size; if (S_ISREG(buf.st_mode)) { computed_size = buf.st_size - reserve_len; } else if (S_ISBLK(buf.st_mode)) { - computed_size = get_block_device_size(fd) - reserve_len; + uint64_t block_device_size = get_block_device_size(fd); + if (block_device_size < reserve_len || + block_device_size > std::numeric_limits::max()) { + computed_size = 0; + } else { + computed_size = block_device_size - reserve_len; + } } else { computed_size = 0; } @@ -231,13 +238,13 @@ int format_volume(const char* volume, const char* directory) { close(fd); } - ssize_t length = 0; + int64_t length = 0; if (v->length != 0) { length = v->length; } else if (v->key_loc != nullptr && strcmp(v->key_loc, "footer") == 0) { android::base::unique_fd fd(open(v->blk_device, O_RDONLY)); if (fd == -1) { - PLOG(ERROR) << "get_file_size: failed to open " << v->blk_device; + PLOG(ERROR) << "format_volume: failed to open " << v->blk_device; return -1; } length = get_file_size(fd.get(), CRYPT_FOOTER_OFFSET); -- cgit v1.2.3 From 2dfc1a38982c4052bb32bc7fc06edeadf3908fb9 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 27 Sep 2017 13:12:11 -0700 Subject: roots: volume_for_path() parses and tries prefixes. Commit cc323958f99e40fea06c511656c69c0b2e2d47f7 in system/core has changed fs_mgr_get_entry_for_mount_point() to do an exact match only, which breaks the behavior in volume_for_path(). This CL changes the volume_for_path() implementation to parse and pass prefixes locally. For a given path like "/cache/recovery/last_log", it will in turn attempt the prefixes of "/cache/recovery/last_log", "/cache/recovery", "/cache", "/" and return the first hit. Bug: 63912287 Test: Build and boot into recovery image on bullhead. 'View recovery logs' works. Change-Id: Ic8635b0939649dd5cc9ca501ebc3a2d1fbf5849d --- roots.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/roots.cpp b/roots.cpp index fdcbfe844..835a1dda0 100644 --- a/roots.cpp +++ b/roots.cpp @@ -68,8 +68,27 @@ void load_volume_table() { printf("\n"); } +// Finds the volume specified by the given path. fs_mgr_get_entry_for_mount_point() does exact match +// only, so it attempts the prefixes recursively (e.g. "/cache/recovery/last_log", +// "/cache/recovery", "/cache", "/" for a given path of "/cache/recovery/last_log") and returns the +// first match or nullptr. Volume* volume_for_path(const char* path) { - return fs_mgr_get_entry_for_mount_point(fstab, path); + if (path == nullptr || path[0] == '\0') return nullptr; + std::string str(path); + while (true) { + Volume* result = fs_mgr_get_entry_for_mount_point(fstab, str.c_str()); + if (result != nullptr || str == "/") { + return result; + } + size_t slash = str.find_last_of('/'); + if (slash == std::string::npos) return nullptr; + if (slash == 0) { + str = "/"; + } else { + str = str.substr(0, slash); + } + } + return nullptr; } // Mount the volume specified by path at the given mount_point. -- cgit v1.2.3 From acba38c2889d210097b76cad1bb0fba9e027a620 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Wed, 27 Sep 2017 17:53:34 -0700 Subject: Move the png open and destroy functions into a class The open_png() function used to open the png file but didn't close it; and this caused the leak of fd. However, we cannot close the file inside open_png() because the png file needs to remain open until the outer function finishes parsing the file and destroys the png struct. This CL addresses this issue by implementing a PngReader class to handle the creation/destruction of the png struct. Bug: 67010912 Test: Run graphic tests; also run locale tests and check fd. Change-Id: I9a803b3cd8c16f16a9ffe8f0acc7fe0f42e95eb0 --- minui/resources.cpp | 565 ++++++++++++++++++++++++++-------------------------- 1 file changed, 279 insertions(+), 286 deletions(-) diff --git a/minui/resources.cpp b/minui/resources.cpp index 756f29d21..837f5ebca 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp @@ -25,10 +25,12 @@ #include #include +#include #include #include #include +#include #include #include @@ -46,89 +48,126 @@ static GRSurface* malloc_surface(size_t data_size) { return surface; } -static int open_png(const char* name, png_structp* png_ptr, png_infop* info_ptr, - png_uint_32* width, png_uint_32* height, png_byte* channels) { - char resPath[256]; - unsigned char header[8]; - int result = 0; - int color_type, bit_depth; - size_t bytesRead; - - snprintf(resPath, sizeof(resPath)-1, "/res/images/%s.png", name); - resPath[sizeof(resPath)-1] = '\0'; - FILE* fp = fopen(resPath, "rbe"); - if (fp == NULL) { - result = -1; - goto exit; - } +// This class handles the png file parsing. It also holds the ownership of the png pointer and the +// opened file pointer. Both will be destroyed/closed when this object goes out of scope. +class PngHandler { + public: + PngHandler(const std::string& name); - bytesRead = fread(header, 1, sizeof(header), fp); - if (bytesRead != sizeof(header)) { - result = -2; - goto exit; - } + ~PngHandler(); - if (png_sig_cmp(header, 0, sizeof(header))) { - result = -3; - goto exit; - } + png_uint_32 width() const { + return width_; + } - *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!*png_ptr) { - result = -4; - goto exit; - } + png_uint_32 height() const { + return height_; + } - *info_ptr = png_create_info_struct(*png_ptr); - if (!*info_ptr) { - result = -5; - goto exit; - } + png_byte channels() const { + return channels_; + } - if (setjmp(png_jmpbuf(*png_ptr))) { - result = -6; - goto exit; - } + png_structp png_ptr() const { + return png_ptr_; + } - png_init_io(*png_ptr, fp); - png_set_sig_bytes(*png_ptr, sizeof(header)); - png_read_info(*png_ptr, *info_ptr); - - png_get_IHDR(*png_ptr, *info_ptr, width, height, &bit_depth, - &color_type, NULL, NULL, NULL); - - *channels = png_get_channels(*png_ptr, *info_ptr); - - if (bit_depth == 8 && *channels == 3 && color_type == PNG_COLOR_TYPE_RGB) { - // 8-bit RGB images: great, nothing to do. - } else if (bit_depth <= 8 && *channels == 1 && color_type == PNG_COLOR_TYPE_GRAY) { - // 1-, 2-, 4-, or 8-bit gray images: expand to 8-bit gray. - png_set_expand_gray_1_2_4_to_8(*png_ptr); - } else if (bit_depth <= 8 && *channels == 1 && color_type == PNG_COLOR_TYPE_PALETTE) { - // paletted images: expand to 8-bit RGB. Note that we DON'T - // currently expand the tRNS chunk (if any) to an alpha - // channel, because minui doesn't support alpha channels in - // general. - png_set_palette_to_rgb(*png_ptr); - *channels = 3; - } else { - fprintf(stderr, "minui doesn't support PNG depth %d channels %d color_type %d\n", - bit_depth, *channels, color_type); - result = -7; - goto exit; - } + png_infop info_ptr() const { + return info_ptr_; + } - return result; + int error_code() const { + return error_code_; + }; - exit: - if (result < 0) { - png_destroy_read_struct(png_ptr, info_ptr, NULL); - } - if (fp != NULL) { - fclose(fp); - } + operator bool() const { + return error_code_ == 0; + } + + private: + png_structp png_ptr_{ nullptr }; + png_infop info_ptr_{ nullptr }; + png_uint_32 width_; + png_uint_32 height_; + png_byte channels_; + + // The |error_code_| is set to a negative value if an error occurs when opening the png file. + int error_code_; + // After initialization, we'll keep the file pointer open before destruction of PngHandler. + std::unique_ptr png_fp_; +}; + +PngHandler::PngHandler(const std::string& name) : error_code_(0), png_fp_(nullptr, fclose) { + std::string res_path = android::base::StringPrintf("/res/images/%s.png", name.c_str()); + png_fp_.reset(fopen(res_path.c_str(), "rbe")); + if (!png_fp_) { + error_code_ = -1; + return; + } + + unsigned char header[8]; + size_t bytesRead = fread(header, 1, sizeof(header), png_fp_.get()); + if (bytesRead != sizeof(header)) { + error_code_ = -2; + return; + } + + if (png_sig_cmp(header, 0, sizeof(header))) { + error_code_ = -3; + return; + } - return result; + png_ptr_ = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); + if (!png_ptr_) { + error_code_ = -4; + return; + } + + info_ptr_ = png_create_info_struct(png_ptr_); + if (!info_ptr_) { + error_code_ = -5; + return; + } + + if (setjmp(png_jmpbuf(png_ptr_))) { + error_code_ = -6; + return; + } + + png_init_io(png_ptr_, png_fp_.get()); + png_set_sig_bytes(png_ptr_, sizeof(header)); + png_read_info(png_ptr_, info_ptr_); + + int color_type; + int bit_depth; + png_get_IHDR(png_ptr_, info_ptr_, &width_, &height_, &bit_depth, &color_type, nullptr, nullptr, + nullptr); + + channels_ = png_get_channels(png_ptr_, info_ptr_); + + if (bit_depth == 8 && channels_ == 3 && color_type == PNG_COLOR_TYPE_RGB) { + // 8-bit RGB images: great, nothing to do. + } else if (bit_depth <= 8 && channels_ == 1 && color_type == PNG_COLOR_TYPE_GRAY) { + // 1-, 2-, 4-, or 8-bit gray images: expand to 8-bit gray. + png_set_expand_gray_1_2_4_to_8(png_ptr_); + } else if (bit_depth <= 8 && channels_ == 1 && color_type == PNG_COLOR_TYPE_PALETTE) { + // paletted images: expand to 8-bit RGB. Note that we DON'T + // currently expand the tRNS chunk (if any) to an alpha + // channel, because minui doesn't support alpha channels in + // general. + png_set_palette_to_rgb(png_ptr_); + channels_ = 3; + } else { + fprintf(stderr, "minui doesn't support PNG depth %d channels %d color_type %d\n", bit_depth, + channels_, color_type); + error_code_ = -7; + } +} + +PngHandler::~PngHandler() { + if (png_ptr_) { + png_destroy_read_struct(&png_ptr_, &info_ptr_, nullptr); + } } // "display" surfaces are transformed into the framebuffer's required @@ -198,178 +237,152 @@ static void transform_rgb_to_draw(unsigned char* input_row, } int res_create_display_surface(const char* name, GRSurface** pSurface) { - GRSurface* surface = NULL; - int result = 0; - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - png_uint_32 width, height; - png_byte channels; - unsigned char* p_row; - unsigned int y; - - *pSurface = NULL; - - result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels); - if (result < 0) return result; - - surface = init_display_surface(width, height); - if (surface == NULL) { - result = -8; - goto exit; - } + *pSurface = nullptr; + + PngHandler png_handler(name); + if (!png_handler) return png_handler.error_code(); + + png_structp png_ptr = png_handler.png_ptr(); + png_uint_32 width = png_handler.width(); + png_uint_32 height = png_handler.height(); + + GRSurface* surface = init_display_surface(width, height); + if (!surface) { + return -8; + } #if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA) - png_set_bgr(png_ptr); + png_set_bgr(png_ptr); #endif - p_row = static_cast(malloc(width * 4)); - for (y = 0; y < height; ++y) { - png_read_row(png_ptr, p_row, NULL); - transform_rgb_to_draw(p_row, surface->data + y * surface->row_bytes, channels, width); - } - free(p_row); + for (png_uint_32 y = 0; y < height; ++y) { + std::vector p_row(width * 4); + png_read_row(png_ptr, p_row.data(), nullptr); + transform_rgb_to_draw(p_row.data(), surface->data + y * surface->row_bytes, + png_handler.channels(), width); + } - *pSurface = surface; + *pSurface = surface; - exit: - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - if (result < 0 && surface != NULL) free(surface); - return result; + return 0; } int res_create_multi_display_surface(const char* name, int* frames, int* fps, - GRSurface*** pSurface) { - GRSurface** surface = NULL; - int result = 0; - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - png_uint_32 width, height; - png_byte channels; - png_textp text; - int num_text; - unsigned char* p_row; - unsigned int y; - - *pSurface = NULL; - *frames = -1; - - result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels); - if (result < 0) return result; - - *frames = 1; - *fps = 20; - if (png_get_text(png_ptr, info_ptr, &text, &num_text)) { - for (int i = 0; i < num_text; ++i) { - if (text[i].key && strcmp(text[i].key, "Frames") == 0 && text[i].text) { - *frames = atoi(text[i].text); - } else if (text[i].key && strcmp(text[i].key, "FPS") == 0 && text[i].text) { - *fps = atoi(text[i].text); - } - } - printf(" found frames = %d\n", *frames); - printf(" found fps = %d\n", *fps); + GRSurface*** pSurface) { + *pSurface = nullptr; + *frames = -1; + + PngHandler png_handler(name); + if (!png_handler) return png_handler.error_code(); + + png_structp png_ptr = png_handler.png_ptr(); + png_uint_32 width = png_handler.width(); + png_uint_32 height = png_handler.height(); + + *frames = 1; + *fps = 20; + png_textp text; + int num_text; + if (png_get_text(png_ptr, png_handler.info_ptr(), &text, &num_text)) { + for (int i = 0; i < num_text; ++i) { + if (text[i].key && strcmp(text[i].key, "Frames") == 0 && text[i].text) { + *frames = atoi(text[i].text); + } else if (text[i].key && strcmp(text[i].key, "FPS") == 0 && text[i].text) { + *fps = atoi(text[i].text); + } } + printf(" found frames = %d\n", *frames); + printf(" found fps = %d\n", *fps); + } - if (*frames <= 0 || *fps <= 0) { - printf("bad number of frames (%d) and/or FPS (%d)\n", *frames, *fps); - result = -10; - goto exit; - } + int result = 0; + GRSurface** surface = nullptr; + if (*frames <= 0 || *fps <= 0) { + printf("bad number of frames (%d) and/or FPS (%d)\n", *frames, *fps); + result = -10; + goto exit; + } - if (height % *frames != 0) { - printf("bad height (%d) for frame count (%d)\n", height, *frames); - result = -9; - goto exit; - } + if (height % *frames != 0) { + printf("bad height (%d) for frame count (%d)\n", height, *frames); + result = -9; + goto exit; + } - surface = static_cast(calloc(*frames, sizeof(GRSurface*))); - if (surface == NULL) { - result = -8; - goto exit; - } - for (int i = 0; i < *frames; ++i) { - surface[i] = init_display_surface(width, height / *frames); - if (surface[i] == NULL) { - result = -8; - goto exit; - } + surface = static_cast(calloc(*frames, sizeof(GRSurface*))); + if (!surface) { + result = -8; + goto exit; + } + for (int i = 0; i < *frames; ++i) { + surface[i] = init_display_surface(width, height / *frames); + if (!surface[i]) { + result = -8; + goto exit; } + } #if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA) - png_set_bgr(png_ptr); + png_set_bgr(png_ptr); #endif - p_row = static_cast(malloc(width * 4)); - for (y = 0; y < height; ++y) { - png_read_row(png_ptr, p_row, NULL); - int frame = y % *frames; - unsigned char* out_row = surface[frame]->data + - (y / *frames) * surface[frame]->row_bytes; - transform_rgb_to_draw(p_row, out_row, channels, width); - } - free(p_row); + for (png_uint_32 y = 0; y < height; ++y) { + std::vector p_row(width * 4); + png_read_row(png_ptr, p_row.data(), nullptr); + int frame = y % *frames; + unsigned char* out_row = surface[frame]->data + (y / *frames) * surface[frame]->row_bytes; + transform_rgb_to_draw(p_row.data(), out_row, png_handler.channels(), width); + } - *pSurface = surface; + *pSurface = surface; exit: - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - - if (result < 0) { - if (surface) { - for (int i = 0; i < *frames; ++i) { - free(surface[i]); - } - free(surface); - } + if (result < 0) { + if (surface) { + for (int i = 0; i < *frames; ++i) { + free(surface[i]); + } + free(surface); } - return result; + } + return result; } int res_create_alpha_surface(const char* name, GRSurface** pSurface) { - GRSurface* surface = NULL; - int result = 0; - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - png_uint_32 width, height; - png_byte channels; + *pSurface = nullptr; - *pSurface = NULL; + PngHandler png_handler(name); + if (!png_handler) return png_handler.error_code(); - result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels); - if (result < 0) return result; + if (png_handler.channels() != 1) { + return -7; + } - if (channels != 1) { - result = -7; - goto exit; - } + png_structp png_ptr = png_handler.png_ptr(); + png_uint_32 width = png_handler.width(); + png_uint_32 height = png_handler.height(); - surface = malloc_surface(width * height); - if (surface == NULL) { - result = -8; - goto exit; - } - surface->width = width; - surface->height = height; - surface->row_bytes = width; - surface->pixel_bytes = 1; + GRSurface* surface = malloc_surface(width * height); + if (!surface) { + return -8; + } + surface->width = width; + surface->height = height; + surface->row_bytes = width; + surface->pixel_bytes = 1; #if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA) - png_set_bgr(png_ptr); + png_set_bgr(png_ptr); #endif - unsigned char* p_row; - unsigned int y; - for (y = 0; y < height; ++y) { - p_row = surface->data + y * surface->row_bytes; - png_read_row(png_ptr, p_row, NULL); - } + for (png_uint_32 y = 0; y < height; ++y) { + unsigned char* p_row = surface->data + y * surface->row_bytes; + png_read_row(png_ptr, p_row, nullptr); + } - *pSurface = surface; + *pSurface = surface; - exit: - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - if (result < 0 && surface != NULL) free(surface); - return result; + return 0; } // This function tests if a locale string stored in PNG (prefix) matches @@ -397,109 +410,89 @@ bool matches_locale(const std::string& prefix, const std::string& locale) { } std::vector get_locales_in_png(const std::string& png_name) { - png_structp png_ptr = nullptr; - png_infop info_ptr = nullptr; - png_uint_32 width, height; - png_byte channels; - - int status = open_png(png_name.c_str(), &png_ptr, &info_ptr, &width, &height, &channels); - if (status < 0) { - printf("Failed to open %s\n", png_name.c_str()); + PngHandler png_handler(png_name); + if (!png_handler) { + printf("Failed to open %s, error: %d\n", png_name.c_str(), png_handler.error_code()); return {}; } - if (channels != 1) { - printf("Expect input png to have 1 data channel, this file has %d\n", channels); - png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); + if (png_handler.channels() != 1) { + printf("Expect input png to have 1 data channel, this file has %d\n", png_handler.channels()); return {}; } std::vector result; - std::vector row(width); - for (png_uint_32 y = 0; y < height; ++y) { - png_read_row(png_ptr, row.data(), nullptr); + std::vector row(png_handler.width()); + for (png_uint_32 y = 0; y < png_handler.height(); ++y) { + png_read_row(png_handler.png_ptr(), row.data(), nullptr); int h = (row[3] << 8) | row[2]; std::string loc(reinterpret_cast(&row[5])); if (!loc.empty()) { result.push_back(loc); } for (int i = 0; i < h; ++i, ++y) { - png_read_row(png_ptr, row.data(), NULL); + png_read_row(png_handler.png_ptr(), row.data(), nullptr); } } - png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); return result; } int res_create_localized_alpha_surface(const char* name, const char* locale, GRSurface** pSurface) { - GRSurface* surface = NULL; - int result = 0; - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - png_uint_32 width, height; - png_byte channels; - png_uint_32 y; - std::vector row; - - *pSurface = NULL; - - if (locale == NULL) { - return result; - } + *pSurface = nullptr; + if (locale == nullptr) { + return 0; + } - result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels); - if (result < 0) return result; + PngHandler png_handler(name); + if (!png_handler) return png_handler.error_code(); - if (channels != 1) { - result = -7; - goto exit; - } + if (png_handler.channels() != 1) { + return -7; + } - row.resize(width); - for (y = 0; y < height; ++y) { - png_read_row(png_ptr, row.data(), NULL); - int w = (row[1] << 8) | row[0]; - int h = (row[3] << 8) | row[2]; - __unused int len = row[4]; - char* loc = reinterpret_cast(&row[5]); - - if (y+1+h >= height || matches_locale(loc, locale)) { - printf(" %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y); - - surface = malloc_surface(w*h); - if (surface == NULL) { - result = -8; - goto exit; - } - surface->width = w; - surface->height = h; - surface->row_bytes = w; - surface->pixel_bytes = 1; - - int i; - for (i = 0; i < h; ++i, ++y) { - png_read_row(png_ptr, row.data(), NULL); - memcpy(surface->data + i*w, row.data(), w); - } + png_structp png_ptr = png_handler.png_ptr(); + png_uint_32 width = png_handler.width(); + png_uint_32 height = png_handler.height(); - *pSurface = surface; - break; - } else { - int i; - for (i = 0; i < h; ++i, ++y) { - png_read_row(png_ptr, row.data(), NULL); - } - } + for (png_uint_32 y = 0; y < height; ++y) { + std::vector row(width); + png_read_row(png_ptr, row.data(), nullptr); + int w = (row[1] << 8) | row[0]; + int h = (row[3] << 8) | row[2]; + __unused int len = row[4]; + char* loc = reinterpret_cast(&row[5]); + + if (y + 1 + h >= height || matches_locale(loc, locale)) { + printf(" %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y); + + GRSurface* surface = malloc_surface(w * h); + if (!surface) { + return -8; + } + surface->width = w; + surface->height = h; + surface->row_bytes = w; + surface->pixel_bytes = 1; + + for (int i = 0; i < h; ++i, ++y) { + png_read_row(png_ptr, row.data(), nullptr); + memcpy(surface->data + i * w, row.data(), w); + } + + *pSurface = surface; + break; } -exit: - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - if (result < 0 && surface != NULL) free(surface); - return result; + for (int i = 0; i < h; ++i, ++y) { + png_read_row(png_ptr, row.data(), nullptr); + } + } + + return 0; } void res_free_surface(GRSurface* surface) { - free(surface); + free(surface); } -- cgit v1.2.3 From ac27a7a98733ea2444eedacfd2d8dd4a384726f6 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 28 Sep 2017 17:43:53 -0700 Subject: otafault: Clean up header inclusion. Remove unneeded #includes. Also remove unneeded dependency on libz and libselinux. Test: mmma bootable/recovery Change-Id: Ic8f7f46f4b89762dee384921504489de75320ac0 --- otafault/Android.mk | 2 -- otafault/config.cpp | 6 ++---- otafault/config.h | 20 +++++++++----------- otafault/ota_io.cpp | 4 +++- otafault/ota_io.h | 3 ++- otafault/test.cpp | 3 ++- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/otafault/Android.mk b/otafault/Android.mk index 4784d56ef..383717612 100644 --- a/otafault/Android.mk +++ b/otafault/Android.mk @@ -18,8 +18,6 @@ include $(CLEAR_VARS) otafault_static_libs := \ libziparchive \ - libz \ - libselinux \ libbase \ liblog diff --git a/otafault/config.cpp b/otafault/config.cpp index b94e429c6..c11f77452 100644 --- a/otafault/config.cpp +++ b/otafault/config.cpp @@ -14,16 +14,14 @@ * limitations under the License. */ +#include "config.h" + #include #include -#include -#include - #include #include -#include "config.h" #include "ota_io.h" #define OTAIO_MAX_FNAME_SIZE 128 diff --git a/otafault/config.h b/otafault/config.h index 4adbdd121..cc4bfd2ad 100644 --- a/otafault/config.h +++ b/otafault/config.h @@ -15,13 +15,13 @@ */ /* - * Read configuration files in the OTA package to determine which files, if any, will trigger errors. + * Read configuration files in the OTA package to determine which files, if any, will trigger + * errors. * - * OTA packages can be modified to trigger errors by adding a top-level - * directory called .libotafault, which may optionally contain up to three - * files called READ, WRITE, and FSYNC. Each one of these optional files - * contains the name of a single file on the device disk which will cause - * an IO error on the first call of the appropriate I/O action to that file. + * OTA packages can be modified to trigger errors by adding a top-level directory called + * .libotafault, which may optionally contain up to three files called READ, WRITE, and FSYNC. + * Each one of these optional files contains the name of a single file on the device disk which + * will cause an IO error on the first call of the appropriate I/O action to that file. * * Example: * ota.zip @@ -29,9 +29,9 @@ * .libotafault * WRITE * - * If the contents of the file WRITE were /system/build.prop, the first write - * action to /system/build.prop would fail with EIO. Note that READ and - * FSYNC files are absent, so these actions will not cause an error. + * If the contents of the file WRITE were /system/build.prop, the first write action to + * /system/build.prop would fail with EIO. Note that READ and FSYNC files are absent, so these + * actions will not cause an error. */ #ifndef _UPDATER_OTA_IO_CFG_H_ @@ -39,8 +39,6 @@ #include -#include - #include #define OTAIO_BASE_DIR ".libotafault" diff --git a/otafault/ota_io.cpp b/otafault/ota_io.cpp index faae5275d..a82a7ee59 100644 --- a/otafault/ota_io.cpp +++ b/otafault/ota_io.cpp @@ -18,15 +18,17 @@ #include #include +#include #include #include +#include #include #include -#include #include #include + #include "config.h" static std::mutex filename_mutex; diff --git a/otafault/ota_io.h b/otafault/ota_io.h index 9428f1b1f..45e481a62 100644 --- a/otafault/ota_io.h +++ b/otafault/ota_io.h @@ -23,8 +23,9 @@ #ifndef _UPDATER_OTA_IO_H_ #define _UPDATER_OTA_IO_H_ +#include #include -#include +#include // mode_t #include diff --git a/otafault/test.cpp b/otafault/test.cpp index 6514782bf..60c40e099 100644 --- a/otafault/test.cpp +++ b/otafault/test.cpp @@ -14,9 +14,10 @@ * limitations under the License. */ -#include #include #include +#include +#include #include #include "ota_io.h" -- cgit v1.2.3 From 646b05a66c52502835d7c301b68b2ebfc4af7e41 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 28 Sep 2017 17:43:53 -0700 Subject: otafault: Remove the use of LOCAL_WHOLE_STATIC_LIBRARIES. Commit d80a99883d5ae2b117c54f076fe1df7eae86d2f8 has explanation of potential issues. Test: mmma bootable/recovery Change-Id: I25ca9920952b7bbdd8a661d9dc90962431410bc4 --- applypatch/Android.mk | 6 ++++-- otafault/Android.mk | 2 +- tests/Android.mk | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/applypatch/Android.mk b/applypatch/Android.mk index 59aa0ce6c..f5dda2bc4 100644 --- a/applypatch/Android.mk +++ b/applypatch/Android.mk @@ -112,11 +112,13 @@ LOCAL_C_INCLUDES := bootable/recovery LOCAL_STATIC_LIBRARIES := \ libapplypatch_modes \ libapplypatch \ - libbase \ libedify \ libotafault \ - libcrypto \ libbspatch \ + libbase \ + libziparchive \ + liblog \ + libcrypto \ libbz LOCAL_SHARED_LIBRARIES := \ libbase \ diff --git a/otafault/Android.mk b/otafault/Android.mk index 383717612..3e14f77f3 100644 --- a/otafault/Android.mk +++ b/otafault/Android.mk @@ -33,7 +33,7 @@ LOCAL_MODULE_TAGS := eng LOCAL_MODULE := libotafault LOCAL_C_INCLUDES := bootable/recovery LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) -LOCAL_WHOLE_STATIC_LIBRARIES := $(otafault_static_libs) +LOCAL_STATIC_LIBRARIES := $(otafault_static_libs) include $(BUILD_STATIC_LIBRARY) diff --git a/tests/Android.mk b/tests/Android.mk index 748d9c87b..31c7de177 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -143,7 +143,6 @@ LOCAL_STATIC_LIBRARIES := \ libdivsufsort \ libdivsufsort64 \ libfs_mgr \ - liblog \ libvintf_recovery \ libvintf \ libtinyxml2 \ @@ -154,6 +153,7 @@ LOCAL_STATIC_LIBRARIES := \ libcrypto \ libbz \ libziparchive \ + liblog \ libutils \ libz \ libbase \ -- cgit v1.2.3 From d33b2f86b79573ccf73fd211d0813b2663fafd38 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 28 Sep 2017 21:29:11 -0700 Subject: otafault: Move headers under otafault/. Test: mmma bootable/recovery Change-Id: I3ceb72f703c7c2857d656c137d71baa1fccd8238 --- applypatch/applypatch.cpp | 2 +- otafault/Android.mk | 11 +++--- otafault/config.cpp | 4 +-- otafault/config.h | 72 -------------------------------------- otafault/include/otafault/config.h | 72 ++++++++++++++++++++++++++++++++++++++ otafault/include/otafault/ota_io.h | 70 ++++++++++++++++++++++++++++++++++++ otafault/ota_io.cpp | 4 +-- otafault/ota_io.h | 70 ------------------------------------ otafault/test.cpp | 2 +- updater/blockimg.cpp | 2 +- updater/install.cpp | 2 +- updater/updater.cpp | 2 +- 12 files changed, 157 insertions(+), 156 deletions(-) delete mode 100644 otafault/config.h create mode 100644 otafault/include/otafault/config.h create mode 100644 otafault/include/otafault/ota_io.h delete mode 100644 otafault/ota_io.h diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp index 51bf3932a..729d2a910 100644 --- a/applypatch/applypatch.cpp +++ b/applypatch/applypatch.cpp @@ -39,7 +39,7 @@ #include #include "edify/expr.h" -#include "ota_io.h" +#include "otafault/ota_io.h" #include "print_sha1.h" static int LoadPartitionContents(const std::string& filename, FileContents* file); diff --git a/otafault/Android.mk b/otafault/Android.mk index 3e14f77f3..5ec8a192a 100644 --- a/otafault/Android.mk +++ b/otafault/Android.mk @@ -31,8 +31,8 @@ LOCAL_CFLAGS := \ LOCAL_SRC_FILES := config.cpp ota_io.cpp LOCAL_MODULE_TAGS := eng LOCAL_MODULE := libotafault -LOCAL_C_INCLUDES := bootable/recovery -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) +LOCAL_C_INCLUDES := $(LOCAL_PATH)/include +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_STATIC_LIBRARIES := $(otafault_static_libs) include $(BUILD_STATIC_LIBRARY) @@ -41,12 +41,13 @@ include $(BUILD_STATIC_LIBRARY) # =============================== include $(CLEAR_VARS) -LOCAL_SRC_FILES := config.cpp ota_io.cpp test.cpp +LOCAL_SRC_FILES := test.cpp LOCAL_MODULE_TAGS := tests LOCAL_MODULE := otafault_test -LOCAL_STATIC_LIBRARIES := $(otafault_static_libs) +LOCAL_STATIC_LIBRARIES := \ + libotafault \ + $(otafault_static_libs) LOCAL_CFLAGS := -Wall -Werror -LOCAL_C_INCLUDES := bootable/recovery LOCAL_FORCE_STATIC_EXECUTABLE := true include $(BUILD_EXECUTABLE) diff --git a/otafault/config.cpp b/otafault/config.cpp index c11f77452..3993948ff 100644 --- a/otafault/config.cpp +++ b/otafault/config.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "config.h" +#include "otafault/config.h" #include #include @@ -22,7 +22,7 @@ #include #include -#include "ota_io.h" +#include "otafault/ota_io.h" #define OTAIO_MAX_FNAME_SIZE 128 diff --git a/otafault/config.h b/otafault/config.h deleted file mode 100644 index cc4bfd2ad..000000000 --- a/otafault/config.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Read configuration files in the OTA package to determine which files, if any, will trigger - * errors. - * - * OTA packages can be modified to trigger errors by adding a top-level directory called - * .libotafault, which may optionally contain up to three files called READ, WRITE, and FSYNC. - * Each one of these optional files contains the name of a single file on the device disk which - * will cause an IO error on the first call of the appropriate I/O action to that file. - * - * Example: - * ota.zip - * - * .libotafault - * WRITE - * - * If the contents of the file WRITE were /system/build.prop, the first write action to - * /system/build.prop would fail with EIO. Note that READ and FSYNC files are absent, so these - * actions will not cause an error. - */ - -#ifndef _UPDATER_OTA_IO_CFG_H_ -#define _UPDATER_OTA_IO_CFG_H_ - -#include - -#include - -#define OTAIO_BASE_DIR ".libotafault" -#define OTAIO_READ "READ" -#define OTAIO_WRITE "WRITE" -#define OTAIO_FSYNC "FSYNC" -#define OTAIO_CACHE "CACHE" - -/* - * Initialize libotafault by providing a reference to the OTA package. - */ -void ota_io_init(ZipArchiveHandle zip, bool retry); - -/* - * Return true if a config file is present for the given IO type. - */ -bool should_fault_inject(const char* io_type); - -/* - * Return true if an EIO should occur on the next hit to /cache/saved.file - * instead of the next hit to the specified file. - */ -bool should_hit_cache(); - -/* - * Return the name of the file that should cause an error for the - * given IO type. - */ -std::string fault_fname(const char* io_type); - -#endif diff --git a/otafault/include/otafault/config.h b/otafault/include/otafault/config.h new file mode 100644 index 000000000..cc4bfd2ad --- /dev/null +++ b/otafault/include/otafault/config.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Read configuration files in the OTA package to determine which files, if any, will trigger + * errors. + * + * OTA packages can be modified to trigger errors by adding a top-level directory called + * .libotafault, which may optionally contain up to three files called READ, WRITE, and FSYNC. + * Each one of these optional files contains the name of a single file on the device disk which + * will cause an IO error on the first call of the appropriate I/O action to that file. + * + * Example: + * ota.zip + * + * .libotafault + * WRITE + * + * If the contents of the file WRITE were /system/build.prop, the first write action to + * /system/build.prop would fail with EIO. Note that READ and FSYNC files are absent, so these + * actions will not cause an error. + */ + +#ifndef _UPDATER_OTA_IO_CFG_H_ +#define _UPDATER_OTA_IO_CFG_H_ + +#include + +#include + +#define OTAIO_BASE_DIR ".libotafault" +#define OTAIO_READ "READ" +#define OTAIO_WRITE "WRITE" +#define OTAIO_FSYNC "FSYNC" +#define OTAIO_CACHE "CACHE" + +/* + * Initialize libotafault by providing a reference to the OTA package. + */ +void ota_io_init(ZipArchiveHandle zip, bool retry); + +/* + * Return true if a config file is present for the given IO type. + */ +bool should_fault_inject(const char* io_type); + +/* + * Return true if an EIO should occur on the next hit to /cache/saved.file + * instead of the next hit to the specified file. + */ +bool should_hit_cache(); + +/* + * Return the name of the file that should cause an error for the + * given IO type. + */ +std::string fault_fname(const char* io_type); + +#endif diff --git a/otafault/include/otafault/ota_io.h b/otafault/include/otafault/ota_io.h new file mode 100644 index 000000000..45e481a62 --- /dev/null +++ b/otafault/include/otafault/ota_io.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Provide a series of proxy functions for basic file accessors. + * The behavior of these functions can be changed to return different + * errors under a variety of conditions. + */ + +#ifndef _UPDATER_OTA_IO_H_ +#define _UPDATER_OTA_IO_H_ + +#include +#include +#include // mode_t + +#include + +#include + +#define OTAIO_CACHE_FNAME "/cache/saved.file" + +void ota_set_fault_files(); + +int ota_open(const char* path, int oflags); + +int ota_open(const char* path, int oflags, mode_t mode); + +FILE* ota_fopen(const char* filename, const char* mode); + +size_t ota_fread(void* ptr, size_t size, size_t nitems, FILE* stream); + +ssize_t ota_read(int fd, void* buf, size_t nbyte); + +size_t ota_fwrite(const void* ptr, size_t size, size_t count, FILE* stream); + +ssize_t ota_write(int fd, const void* buf, size_t nbyte); + +int ota_fsync(int fd); + +struct OtaCloser { + static void Close(int); +}; + +using unique_fd = android::base::unique_fd_impl; + +int ota_close(unique_fd& fd); + +struct OtaFcloser { + void operator()(FILE*) const; +}; + +using unique_file = std::unique_ptr; + +int ota_fclose(unique_file& fh); + +#endif diff --git a/otafault/ota_io.cpp b/otafault/ota_io.cpp index a82a7ee59..1308973a5 100644 --- a/otafault/ota_io.cpp +++ b/otafault/ota_io.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "ota_io.h" +#include "otafault/ota_io.h" #include #include @@ -29,7 +29,7 @@ #include -#include "config.h" +#include "otafault/config.h" static std::mutex filename_mutex; static std::map filename_cache GUARDED_BY(filename_mutex); diff --git a/otafault/ota_io.h b/otafault/ota_io.h deleted file mode 100644 index 45e481a62..000000000 --- a/otafault/ota_io.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Provide a series of proxy functions for basic file accessors. - * The behavior of these functions can be changed to return different - * errors under a variety of conditions. - */ - -#ifndef _UPDATER_OTA_IO_H_ -#define _UPDATER_OTA_IO_H_ - -#include -#include -#include // mode_t - -#include - -#include - -#define OTAIO_CACHE_FNAME "/cache/saved.file" - -void ota_set_fault_files(); - -int ota_open(const char* path, int oflags); - -int ota_open(const char* path, int oflags, mode_t mode); - -FILE* ota_fopen(const char* filename, const char* mode); - -size_t ota_fread(void* ptr, size_t size, size_t nitems, FILE* stream); - -ssize_t ota_read(int fd, void* buf, size_t nbyte); - -size_t ota_fwrite(const void* ptr, size_t size, size_t count, FILE* stream); - -ssize_t ota_write(int fd, const void* buf, size_t nbyte); - -int ota_fsync(int fd); - -struct OtaCloser { - static void Close(int); -}; - -using unique_fd = android::base::unique_fd_impl; - -int ota_close(unique_fd& fd); - -struct OtaFcloser { - void operator()(FILE*) const; -}; - -using unique_file = std::unique_ptr; - -int ota_fclose(unique_file& fh); - -#endif diff --git a/otafault/test.cpp b/otafault/test.cpp index 60c40e099..63e2445af 100644 --- a/otafault/test.cpp +++ b/otafault/test.cpp @@ -20,7 +20,7 @@ #include #include -#include "ota_io.h" +#include "otafault/ota_io.h" int main(int /* argc */, char** /* argv */) { int fd = open("testdata/test.file", O_RDWR); diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index fe21dd0eb..696cddf41 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -51,7 +51,7 @@ #include "edify/expr.h" #include "error_code.h" -#include "ota_io.h" +#include "otafault/ota_io.h" #include "print_sha1.h" #include "rangeset.h" #include "updater/install.h" diff --git a/updater/install.cpp b/updater/install.cpp index 8e54c2e75..fc085d5aa 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -59,7 +59,7 @@ #include "edify/expr.h" #include "error_code.h" #include "mounts.h" -#include "ota_io.h" +#include "otafault/ota_io.h" #include "otautil/DirUtil.h" #include "print_sha1.h" #include "tune2fs.h" diff --git a/updater/updater.cpp b/updater/updater.cpp index 1d8fa8e92..e10174f71 100644 --- a/updater/updater.cpp +++ b/updater/updater.cpp @@ -30,8 +30,8 @@ #include #include -#include "config.h" #include "edify/expr.h" +#include "otafault/config.h" #include "otautil/DirUtil.h" #include "otautil/SysUtil.h" #include "updater/blockimg.h" -- cgit v1.2.3 From a26e32d2a366c8319944b2ac887a175a870f034d Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 28 Sep 2017 18:46:19 -0700 Subject: otafault: Move to soong. Test: mmma bootable/recovery Change-Id: I5f2520ea457ba66743aa3aa1d5b3b488a93084a3 --- Android.bp | 1 + Android.mk | 1 - otafault/Android.bp | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ otafault/Android.mk | 53 ---------------------------------------------- 4 files changed, 61 insertions(+), 54 deletions(-) create mode 100644 otafault/Android.bp delete mode 100644 otafault/Android.mk diff --git a/Android.bp b/Android.bp index 49438ad9e..99ca3a45c 100644 --- a/Android.bp +++ b/Android.bp @@ -1,4 +1,5 @@ subdirs = [ "bootloader_message", + "otafault", "otautil", ] diff --git a/Android.mk b/Android.mk index 801141249..c55771fbe 100644 --- a/Android.mk +++ b/Android.mk @@ -263,7 +263,6 @@ include \ $(LOCAL_PATH)/edify/Android.mk \ $(LOCAL_PATH)/minadbd/Android.mk \ $(LOCAL_PATH)/minui/Android.mk \ - $(LOCAL_PATH)/otafault/Android.mk \ $(LOCAL_PATH)/tests/Android.mk \ $(LOCAL_PATH)/tools/Android.mk \ $(LOCAL_PATH)/uncrypt/Android.mk \ diff --git a/otafault/Android.bp b/otafault/Android.bp new file mode 100644 index 000000000..91a5d9a54 --- /dev/null +++ b/otafault/Android.bp @@ -0,0 +1,60 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +cc_library_static { + name: "libotafault", + + srcs: [ + "config.cpp", + "ota_io.cpp", + ], + + static_libs: [ + "libbase", + "liblog", + "libziparchive", + ], + + export_include_dirs: [ + "include", + ], + + cflags: [ + "-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS", + "-Wall", + "-Werror", + "-Wthread-safety", + "-Wthread-safety-negative", + ], +} + +cc_test { + name: "otafault_test", + + srcs: ["test.cpp"], + + cflags: [ + "-Wall", + "-Werror", + ], + + static_executable: true, + + static_libs: [ + "libotafault", + "libziparchive", + "libbase", + "liblog", + ], +} diff --git a/otafault/Android.mk b/otafault/Android.mk deleted file mode 100644 index 5ec8a192a..000000000 --- a/otafault/Android.mk +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 2015 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific languae governing permissions and -# limitations under the License. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -otafault_static_libs := \ - libziparchive \ - libbase \ - liblog - -LOCAL_CFLAGS := \ - -Wall \ - -Werror \ - -Wthread-safety \ - -Wthread-safety-negative \ - -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS - -LOCAL_SRC_FILES := config.cpp ota_io.cpp -LOCAL_MODULE_TAGS := eng -LOCAL_MODULE := libotafault -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include -LOCAL_STATIC_LIBRARIES := $(otafault_static_libs) - -include $(BUILD_STATIC_LIBRARY) - -# otafault_test (static executable) -# =============================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := test.cpp -LOCAL_MODULE_TAGS := tests -LOCAL_MODULE := otafault_test -LOCAL_STATIC_LIBRARIES := \ - libotafault \ - $(otafault_static_libs) -LOCAL_CFLAGS := -Wall -Werror -LOCAL_FORCE_STATIC_EXECUTABLE := true - -include $(BUILD_EXECUTABLE) -- cgit v1.2.3