Commit graph

101 commits

Author SHA1 Message Date
Tianjie Xu
7aa88748f6 Turn on -Werror for recovery
Also remove the 0xff comparison when validating the bootloader
message fields. As the fields won't be erased to 0xff after we
remove the MTD support.

Bug: 28202046
Test: The recovery folder compiles for aosp_x86-eng
Change-Id: Ibb30ea1b2b28676fb08c7e92a1e5f7b6ef3247ab
2016-09-29 19:21:24 -07:00
Tianjie Xu
61590bbf0d Merge "Switch recovery to libbase logging" 2016-09-01 23:04:37 +00:00
Tianjie Xu
7b0ad9c638 Switch recovery to libbase logging
Clean up the recovery image and switch to libbase logging.

Bug: 28191554
Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35
Merged-In: Icd999c3cc832f0639f204b5c36cea8afe303ad35
2016-09-01 18:33:25 +00:00
Tianjie Xu
71e182bc38 Check an edge case when read(2) returns 0
We might end up in an infinite loop if read(2) reached EOF unexpectedly.
The problematic code in uncrypt mentioned in the bug has been fixed
by switching to libbase ReadFully(). So I grepped through the recovery
code and fixed some other occurences of the issue.

Bug: 31073201
Change-Id: Ib867029158ba23363b8f85d61c25058a635c5a6b
2016-08-31 19:11:41 -07:00
Josh Gao
dc97404346 Merge "Fix references to libcrypto_utils_static."
am: b97da5e0f0

Change-Id: Ia935df84e5ea36dfc6605b41872c36db69a114a0
2016-08-08 18:33:51 +00:00
Josh Gao
073164f24b Fix references to libcrypto_utils_static.
Bug: http://b/30708454
Change-Id: I7a5048beff1d8b783a9683dcb4a79606a77f20ee
2016-08-05 18:08:03 -07:00
Elliott Hughes
274d17dc0f resolve merge conflicts of 179c0d8 to stage-aosp-master
Change-Id: Iba5aec266444cabf83f600f2bdb45a3c027e5995
2016-06-15 15:22:17 -07:00
Tao Bao
38afad46d8 resolve merge conflicts of 490fad6 to nyc-dev-plus-aosp
Change-Id: I299fe15977c1a59d0c784728872c3a7f63c95e56
2016-06-13 19:12:46 -07:00
Tao Bao
490fad6791 applypatch: Don't call inflate() when it expects zero-length output.
We may have expanded_len == 0 when calling inflate(). After switching to
using std::vector, it passes a nullptr buffer to inflate() and leads to
Z_STREAM_ERROR.

Bug: 29312140
Change-Id: Iab7c6c07a9e8488e844e7cdda76d02bd60d2ea98
2016-06-13 16:42:52 -07:00
Elliott Hughes
63a319201f Remove obsolete MTD support.
Bug: http://b/29250988
Change-Id: Ia97ba9082a165c37f74d6e1c3f71a367adc59945
2016-06-10 13:45:35 -07:00
Tao Bao
a0c4011028 Revert "Fix memory/resource handling in imgdiff.cpp, using unique_ptr and vector."
This reverts commit 50a6f8c833.

A mix of new and free leads to memory corruptions.
2016-06-01 13:15:44 -07:00
Adam Buchbinder
50a6f8c833 Fix memory/resource handling in imgdiff.cpp, using unique_ptr and vector.
This fixes the following cppcheck reports:
[imgdiff.cpp:197]: (error) Memory leak: img
[imgdiff.cpp:386]: (error) Memory leak: img
[imgdiff.cpp:656]: (error) Memory leak: data
[imgdiff.cpp:664]: (error) Memory leak: data
[imgdiff.cpp:668]: (error) Memory leak: data
[imgdiff.cpp:668]: (error) Resource leak: f
[imgdiff.cpp:820]: (error) Memory leak: bonus_data
[imgdiff.cpp:824]: (error) Memory leak: bonus_data
[imgdiff.cpp:824]: (error) Resource leak: f
[imgdiff.cpp:847]: (error) Memory leak: bonus_data
[imgdiff.cpp:851]: (error) Memory leak: bonus_data
[imgdiff.cpp:856]: (error) Memory leak: bonus_data
[imgdiff.cpp:860]: (error) Memory leak: bonus_data
[imgdiff.cpp:227]: (error) Memory leak: temp_entries

Change-Id: I06f878d0b677a25328e0deb84f65f3b7212e24b1
(cherry picked from commit 51dc9444bc)
2016-06-01 10:28:45 -07:00
Tao Bao
16e3861c84 Revert "imgdiff: Generate statically linked imgdiff."
This reverts commit b4422bd769.

Bug: 28941046
Change-Id: Ic3c7439c64b8e55832252850514f721a944993d6
2016-06-01 00:08:40 +00:00
Tao Bao
b4422bd769 imgdiff: Generate statically linked imgdiff.
Bug: 28941046
Change-Id: If3019d8cff91fd4f6fa4516bef5a0f51c2ddebc7
2016-05-30 21:53:11 -07:00
Sen Jiang
2fffcb174b applypatch: Use bsdiff from external/bsdiff.
external/bsdiff uses divsufsort which is much faster, and also include
some bug fixes.

Bug: 26982501
Test: ./imgdiff_test.sh

Change-Id: I089a301c291ee55d79938c7a3ca6d509895440d1
2016-05-03 16:39:51 -07:00
Chih-Hung Hsieh
54a2747ef3 Fix google-runtime-int warnings.
Bug: 28220065
Change-Id: Ida199c66692a1638be6990d583d2ed42583fb592
2016-04-18 12:29:30 -07:00
Jed Estep
ff6df890a2 Control fault injection with config files instead of build flags
Bug: 27724259
Change-Id: I65bdefed10b3fb85fcb9e1147eaf0687d7d438f4
2016-03-18 17:58:25 -07:00
Tao Bao
ce5868862a Revert "DO NOT MERGE Control fault injection with config files instead of build flags"
This reverts commit f73abf36bc.

Bug: 27724259
Change-Id: I1301fdad15650837d0b1febd0c3239134e2b94fb
2016-03-17 22:29:23 +00:00
Jed Estep
f73abf36bc DO NOT MERGE Control fault injection with config files instead of build flags
Bug: 26570379
Change-Id: I76109d09276d6e3ed3a32b6fedafb2582f545c0c
2016-03-16 12:36:57 -07:00
Alex Deymo
82f8c82046 Add include/ to the Makefile include path.
The applypatch heaaders were recently moved to the include/ directory.
This patch reflects that change in the Makefile.

Bug: None
TEST=sudo emerge imgdiff

Change-Id: I0bf3f991b5e0c98054033c5939ed69b3e3c827a9
2016-03-14 14:25:33 -07:00
Yabin Cui
1c522df25f applypatch: use vector to store data in FileContents.
Cherry pick this patch because it fixes the problem that
a newed Value is released by free().

Bug: 26906416
Change-Id: Ib53b445cd415a1ed5e95733fbc4073f9ef4dbc43
(cherry picked from commit d6c93afcc2)
2016-03-11 11:11:11 -08:00
Sen Jiang
5593342575 Merge "applypatch: add -fPIC for libimgpatch in Chrome OS." 2016-03-09 01:28:09 +00:00
Sen Jiang
ef2016f711 applypatch: add -fPIC for libimgpatch in Chrome OS.
To make the static library position independent.

Bug: 26866274
Test: emerge-peppy imgdiff; sudo emerge imgdiff; emerge nyan imgdiff

Change-Id: I319e721ccfb6a51f63d31afa49f54aa7f607f4bf
2016-03-08 17:02:50 -08:00
Tao Bao
d80a99883d Fix the improper use of LOCAL_WHOLE_STATIC_LIBRARIES.
If two libraries both use LOCAL_WHOLE_STATIC_LIBRARIES and include a same
library, there would be linking errors when generating a shared library
(or executable) that depends on the two libraries both.

Also clean up Android.mk files.

Remove the "LOCAL_MODULE_TAGS := eng" line for the updater module. The
module will then default to "optional" which won't be built until needed.

Change-Id: I3ec227109b8aa744b7568e7f82f575aae3fe0e6f
2016-03-03 14:52:44 -08:00
Jed Estep
39c1b5e872 Control fault injection with config files instead of build flags
Bug: 26570379
Change-Id: I76109d09276d6e3ed3a32b6fedafb2582f545c0c
(cherry picked from commit d940887dde)
2016-02-22 17:31:12 -08:00
Sen Jiang
f3e05f504d applypatch: Add libimgpatch.pc
Test: pkg-config --libs libimgpatch
Bug: 26866274
Change-Id: I79a103099d951943a88768c577224fccacbb79e3
2016-02-16 11:35:29 -08:00
Sen Jiang
fa4f1b75b6 imgdiff: don't fail if gzip is corrupted.
Treat it as a normal chunk if inflate() fails.

Test: run imgdiff on corrupted gzip and apply the patch
Bug: 27153028
Change-Id: Idcbb3c1360ec0774e6c7861b21d99af8ee10604a
2016-02-12 12:57:03 -08:00
Yabin Cui
d6c93afcc2 applypatch: use vector to store data in FileContents.
Bug: 26906416
Change-Id: Ib53b445cd415a1ed5e95733fbc4073f9ef4dbc43
2016-02-11 18:10:31 -08:00
Jed Estep
a7b9a4660c IO fault injection for OTA packages
Bug: 25951086
Change-Id: I31c74c735eb7a975b7f41fe2b2eff042e5699c0c
(cherry-picked from commit f1fc48c6e6)
2016-02-10 10:49:38 -08:00
Sen Jiang
696692a3c9 applypatch: Add a Makefile to build imgdiff in Chrome OS.
Also fixed some warnings and added check for target_len.

Test: mma; emerge-peppy imgdiff; emerge-nyan imgdiff; sudo emerge imgdiff
Bug: 26866274

Change-Id: Ifbcd3afd6701c769ccf626e33ed94461706f7ee6
2016-02-09 15:26:57 -08:00
Yabin Cui
ca78c9f035 resolve merge conflicts of 715d8a203a to master.
Change-Id: Ic868ee9b27ef7251aa49ac814de7355ecd9c7d37
2016-02-05 15:27:52 -08:00
Yabin Cui
d483c20a7e applypatch: fix memory leaks reported by static analysis.
Bug: 26906416
Change-Id: I163df5a8f3abda3ba5d4ed81dfc8567054eceb27
2016-02-04 15:42:02 -08:00
Tao Bao
50aa63f9bd resolve merge conflicts of 7b6027dde4 to master.
Change-Id: I1d5232f61744bb18ca5de3a16a340bc3afd110bb
2016-02-04 11:26:29 -08:00
Sen Jiang
c48cb5e597 Switch from mincrypt to BoringSSL in applypatch and updater.
Bug: 18790686
Change-Id: I7d2136fb39b2266f5ae5be24819c617b08a6c21e
2016-02-04 16:27:43 +08:00
Tao Bao
9fcb016109 Merge "Fix build." am: 9d72d4175b
am: 2ab24d36b9

* commit '2ab24d36b91e28416a85e2c56442c22c984903ea':
  Fix build.
2016-01-29 06:09:04 +00:00
Tao Bao
8b0db11eba Fix build.
Disable libimgpatch for non-Linux host.

Change-Id: Ib3615204b76564c691ddafaa29e59fef334d9d36
2016-01-28 21:59:09 -08:00
Tao Bao
484c49e99e resolve merge conflicts of 725833e024 to master.
Change-Id: I68b8737e3bc2bd7bffd7625114723bc1efa47398
2016-01-28 20:58:59 -08:00
Sen Jiang
0cce9cda0c applypatch: Compile libimgpatch for target and host.
update_engine need it for the new IMGDIFF operation.

Also removed __unused in ApplyImagePatch() as I got error building it
for the host, and I think it's dangerous not checking the size of the
input.

Test: mma
Bug: 26628339

Change-Id: I22d4cd55c2c3f87697d6afdf10e8106fef7d1a9c
2016-01-28 13:26:25 +08:00
Jed Estep
f1fc48c6e6 IO fault injection for OTA packages
Bug: 25951086
Change-Id: I31c74c735eb7a975b7f41fe2b2eff042e5699c0c
2016-01-06 12:23:42 -08:00
David Riley
0779fc9814 imgdiff: skip spurious gzip headers in image files
dragon kernel is compressed via lz4 for boot speed and bootloader
support reasons and recent prebuilts happen to include the gzip header
sequence which is causing imgdiff to fail.

Detect a spurious gzip header and treat the section as a normal section.

Bug: 26133184
Change-Id: I369d7d576fd7d2c579c0780fc5c669a5b6ea0d3d
(cherry picked from commit 0f2f6a746af517afca9e5e089a4a17be0a9766d6)
Signed-off-by: David Riley <davidriley@google.com>
2015-12-23 09:43:59 -08:00
Elliott Hughes
4b166f0e69 Track rename from base/ to android-base/.
Change-Id: I354a8c424d340a9abe21fd716a4ee0d3b177d86f
2015-12-04 15:30:20 -08:00
Tao Bao
f2448d0cd5 Remove the building rules for applypatch_static.
The CL in [1] has stopped building and packaging the obsolete
applypatch_static tool.

[1]: commit a04fca31bf1fadcdf982090c942ccbe4d9b95c71

Bug: 24621915
Change-Id: I5e98951ad7ea5c2a7b351af732fd6722763f59bd
2015-12-02 14:05:38 -08:00
Jeremy Compostella
a91c66d7c1 imgdiff: fix file descriptor leak
mkstemp() allocates a file description that is never released.  If
MakePatch() is called too many time, imgdiff reaches the Operating
System EMFILE (too many open files) limit.

Change-Id: Icbe1399f6f6d32cfa1830f879cacf7d75bbd9fc3
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Signed-off-by: Gaelle Nassiet <gaellex.nassiet@intel.com>
2015-09-08 19:15:09 +02:00
Tao Bao
e6aa3326c1 updater: Clean up char* with std::string.
So we can remove a few free()s. And also replace a few pointers with
references.

Change-Id: I4b6332216704f4f9ea4a044b8d4bb7aa42a7ef26
2015-08-06 13:05:00 -07:00
Tao Bao
1ce7a2a63d applypatch: Fix the checking in WriteToPartition().
WriteToPartition() should consider a target name as valid if it contains
multiple colons. But only the first two fields will be used.

Bug: 22725128
Change-Id: Ie9404375e24045c115595eec6ce5b6423da8fc3e
2015-07-24 15:33:35 -07:00
Tao Bao
abba55b4c5 applypatch: Support flash mode.
We may carry a full copy of recovery image in the /system, and use
/system/bin/install-recovery.sh to install the recovery. This CL adds
support to flash the recovery partition with the given image.

Bug: 22641135
Change-Id: I7a275b62fdd1bf41f97f6aab62d0200f7dae5aa1
(cherry picked from commit 68c5a67967)
2015-07-24 11:15:19 -07:00
Tao Bao
aca8e89603 applypatch: Refactor strtok().
We have android::base::Split() for the work.

Change-Id: I0fb562feb203c9b15e2f431d8e84355fd682376a
(cherry picked from commit 0a47ce27de)
2015-07-24 11:08:14 -07:00
Tao Bao
ba9a42aa7e recovery: Switch applypatch/ and updater/ to cpp.
Mostly trivial changes to make cpp compiler happy.

Change-Id: I69bd1d96fcccf506007f6144faf37e11cfba1270
2015-07-13 17:21:31 -07:00
Tao Bao
80e46e08de recovery: Switch to clang
And a few trival fixes to suppress warnings.

Change-Id: I38734b5f4434643e85feab25f4807b46a45d8d65
2015-06-03 11:30:03 -07:00
caozhiyuan
3b4977638f Use f_bavail to calculate free space
Failures are seen on devices with
Linux 3.10. And they are mainly due to this change:
https://lwn.net/Articles/546473/
The blocks reserved in this change is not the same thing as what we
think are reserved for common usage of root user. And this part is
included in free blocks but not in available blocks.

Change-Id: Ib29e12d775b86ef657c0af7fa7a944d2b1e12dc8
2015-05-29 13:32:49 +08:00