Commit graph

360 commits

Author SHA1 Message Date
Sergio Giro
3411dd4457 libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8
Inconsistent behaviour between utf16_to_utf8 and utf16_to_utf8_length
is causing a heap overflow.

Correcting the length computation and adding bound checks to the
conversion functions.

Test: ran libutils_tests
Bug: 29250543
Change-Id: I6115e3357141ed245c63c6eb25fc0fd0a9a7a2bb
(cherry picked from commit c4966a363e)
2016-07-14 16:49:50 +01:00
Sergio Giro
e059f5e325 Revert \\\\\\\"libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8\\\\\\\" am: 311002936e am: ddd0051968 am: b218b2d34d am: 605de74373 am: 37826f5613 am: 80473d5d33
am: c06d338ad7

Change-Id: I4ee28f7eb936464eeee476b9fedb19aa7fb96ac0
2016-07-13 13:01:47 +00:00
Sergio Giro
c06d338ad7 Revert \\\\\\"libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8\\\\\\" am: 311002936e am: ddd0051968 am: b218b2d34d am: 605de74373 am: 37826f5613
am: 80473d5d33

Change-Id: Ia5cb6e89924e69df568d633472656dd4b0c12a76
2016-07-13 12:58:09 +00:00
Sergio Giro
605de74373 Revert \\\"libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8\\\" am: 311002936e am: ddd0051968
am: b218b2d34d

Change-Id: Iced8e47993a39103aed3deafb5deb974995ecdba
2016-07-13 12:47:25 +00:00
Sergio Giro
b218b2d34d Revert \\"libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8\\" am: 311002936e
am: ddd0051968

Change-Id: Ia2a422c170a0d700a1d4d55ea920361689a9be8b
2016-07-13 12:44:00 +00:00
Sergio Giro
311002936e Revert "libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8"
This reverts commit 53473c1607.

Change-Id: I27379317e08ecbd5e3b95b7ece58194838ab6c21
2016-07-13 11:47:53 +00:00
Sergio Giro
6025b216e4 libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8 am: 53473c1607 am: 41e6690d0c am: 29ccafe5f0 am: fd7bd2dfef am: 498ffa62c5 am: 5e4ebd02d4
am: d837e74381

Change-Id: Ie620548a78c92d2160db4395f00c6ec9f281e937
2016-07-13 09:55:54 +00:00
Sergio Giro
d837e74381 libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8 am: 53473c1607 am: 41e6690d0c am: 29ccafe5f0 am: fd7bd2dfef am: 498ffa62c5
am: 5e4ebd02d4

Change-Id: Ib2eb019edba21cd3ba3e22d745818d30c912ce62
2016-07-13 09:52:14 +00:00
Sergio Giro
fd7bd2dfef libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8 am: 53473c1607 am: 41e6690d0c
am: 29ccafe5f0

Change-Id: If7c24750afcae3a4b73885b2c4fb9b99ffca5c45
2016-07-13 09:41:12 +00:00
Sergio Giro
29ccafe5f0 libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8 am: 53473c1607
am: 41e6690d0c

Change-Id: I0f7707c88684f9cc24fff878d3d3751b6025227f
2016-07-13 09:37:36 +00:00
Sergio Giro
53473c1607 libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8
Inconsistent behaviour between utf16_to_utf8 and utf16_to_utf8_length
is causing a heap overflow.

Correcting the length computation and adding bound checks to the
conversion functions.

(cherry picked from commit c4966a363e)
(changed code for safetynet logging due to lack of sstream and string in klp)

Change-Id: If50d59a91a13fddbff9a8fff0d3eebe57c711e93
Bug: 29250543
2016-07-12 18:39:11 +01:00
Michael Lentine
6078805023 Adding a build id check to blob cache.
Add a build id field to the header structure in blob cache. Add build
id support with reading and writing the cache. When the cache gets
written it writes the build id at the end of the header. When read it
checks to see if there is a match between the current version and the
version in the cache. If not, it invalidates the cache which would
typically only occur during an ota update.  Also remove blob cache
from the host build.

bug: 18262905

Change-Id: I753b1de1986703a4c1c8691b9d2bb533b2546143
2015-05-18 13:14:32 -07:00
John Reck
52fc3e9aa8 Move LinearAlloc to libhwui
Change-Id: I83a70959ed0dcab2237faaf1dddc02b5eb0363c9
2015-04-23 15:07:54 -07:00
Michael Wright
835d9ca034 am 97147ef2: am a7d47092: am a75b3de2: Merge "Mark time conversion functions as constexpr"
* commit '97147ef2cd09bef1f348375611905864fa0fd068':
  Mark time conversion functions as constexpr
2015-04-21 23:27:12 +00:00
Michael Wright
65e93c3b6f Mark time conversion functions as constexpr
Change-Id: I753c6975a8e1d78978c31175b2e1868eb374c442
2015-04-20 15:06:01 +01:00
Elliott Hughes
3bb04bd804 am 6c7c6d04: am 7c194525: am ea975880: Merge "Only Windows doesn\'t have %zd."
* commit '6c7c6d0420ca837b81927b2f7c08cd9d92533043':
  Only Windows doesn't have %zd.
2015-04-03 20:58:29 +00:00
Elliott Hughes
146c244613 Only Windows doesn't have %zd.
Change-Id: Ie09619df212cf7c8aa18a6d46c3e6b6ca3f478cf
2015-04-03 12:53:36 -07:00
Tim Kilbourn
8892ce6383 Use eventfd instead of pipe in Looper.
Bug: 19933224
Change-Id: I6611e918db960bbb0e74f8308e10bdf79510b899
2015-03-27 09:15:43 -07:00
Dan Albert
ac197dd2af am 1188a4d8: am a596623f: am 6ccfabcf: Merge "O_CLOEXEC is O_NOINHERIT on Windows."
* commit '1188a4d856f6c840a2d39c44e35ba3f3cd86b3a5':
  O_CLOEXEC is O_NOINHERIT on Windows.
2015-03-27 06:55:14 +00:00
Dan Albert
c6b30f376d O_CLOEXEC is O_NOINHERIT on Windows.
Change-Id: I714aa08344fa10684c99651f953834086cc162c7
2015-03-26 23:24:15 -07:00
Dan Albert
a83ba64a23 Revert "Revert "Create libbase.""
This reverts commit a7870d8816.

(cherry picked from commit c007bc3856)
2015-03-16 13:48:07 -07:00
Dan Albert
c007bc3856 Revert "Revert "Create libbase.""
This reverts commit a7870d8816.
2015-03-16 10:08:46 -07:00
Nicolas Geoffray
a6000e81dc am 90a968f0: am dd581695: Merge "Revert "Create libbase.""
* commit '90a968f0e3fb903aad41f6689c337a7e4a8d5c7b':
  Revert "Create libbase."
2015-03-16 11:25:38 +00:00
Nicolas Geoffray
a7870d8816 Revert "Create libbase."
Breaks internal master.

This reverts commit 98ff77204c.

Change-Id: I18dc6021cb43efff8aa88486c2d980dc2b8eedba
2015-03-16 11:07:29 +00:00
Dan Albert
06d60af714 am 517f65da: am a68c8148: Merge "Create libbase."
* commit '517f65daef177d06d7835300a1c23ce3409c0643':
  Create libbase.
2015-03-15 22:33:53 +00:00
Dan Albert
98ff77204c Create libbase.
Move StringPrintf and the string based file I/O from libutils to
libbase.

Change-Id: I0297a6063874b9d92100e0dd5123fddfbda932fe
2015-03-14 16:36:18 -07:00
Jeff Brown
e7d54f80cb Fix issues related to removing Looper callbacks after close.
When a file descriptor is closed before removing it from the
epoll set, it will normally be removed automatically from the
epoll set by the kernel.  However if there exists a duplicate
then the original file descriptor may remain in the set and
continue to receive events until all duplicates have been closed.

Unfortunately due to kernel limitations we need to rebuild the epoll
set from scratch because it may contain an old file handle that we are
now unable to remove since its file descriptor is no longer valid.
No such problem would have occurred if we were using the poll system
call instead, but that approach carries others disadvantages.

Bug: 19715279
Change-Id: If1ab8ebda0825755a416d513e888942a02ee3948
2015-03-12 19:44:49 -07:00
Jeff Brown
7a0310ef67 Fixed subtle bugs related to file descriptor recycling.
Added code to protect against situations that may occur when a
Looper callback has the side-effect of closing the file descriptor that
it is watching before it returns.  This code pattern is very
convenient for implementation but it does expose issues in how
the list of callbacks is maintained.  In particular, we
need to watch out for file descriptors which have been reused.

This change may resolve previously unexplained ANRs associated with
log messages such as: "Error modifying epoll events for fd 44, errno=2"

Bug: 10349083
Change-Id: I20eedf6ffbdeda382653ca0104962505194741b0
2015-03-11 15:00:36 -07:00
Jeff Brown
27e5721860 Rename Looper::isIdling() to isPolling() to resolve confusion.
The loop isn't technically idle at this time, it's just checking
whether any file descriptors have pending events.  However it's
still a good signal as to whether the loop is alive.

Bug: 19532373
Change-Id: I555c473e70ffd8a56e1b10aa60026eb674a16de9
2015-03-11 15:00:36 -07:00
Narayan Kamath
6832a7a4e0 Remove useless refCounting from FileMap.
Nobody ever called acquire() so release() was always
equivalent to delete. Just use delete instead so that
people can use unique_ptr directly (or shared_ptr if
they really want refcounts).

Change-Id: I9e3ad5e0f6a4fcc4e02e5a2ff7ef9514fe234415
2015-02-23 15:49:43 +00:00
Elliott Hughes
f682b4786a Clean up reading and writing in init.
This isn't particularly useful in and of itself, but it does introduce the
first (trivial) unit test, improves the documentation (including details
about how to debug init crashes), and made me aware of how unpleasant the
existing parser is.

I also fixed a bug in passing --- unless you thought the "peboot" and "pm"
commands were features...

Bug: 19217569
Change-Id: I6ab76129a543ce3ed3dab52ef2c638009874c3de
2015-02-06 14:20:30 -08:00
Elliott Hughes
d79801d60d Fix Windows build.
Take 2. Probably should have done this in the beginning, but thought I was
being clever.

Change-Id: I85c6e487eece9bcc75f8f62c850c2d4d1ee9e908
2015-02-05 08:21:37 -08:00
Elliott Hughes
202f024dee Add a WriteStringToFile overload that cares about permissions.
Change-Id: I857a80b61768d4e9610bdd149eff2d9d8e48d2c0
2015-02-04 14:30:23 -08:00
Elliott Hughes
e44d25d645 Merge "Add Google-style StringPrintf." 2015-02-03 23:23:11 +00:00
Elliott Hughes
6b3be2902d Add Google-style StringPrintf.
Change-Id: If333c28b8ed047346a2dd85e591c4bedbab874cc
2015-02-03 15:21:07 -08:00
Elliott Hughes
714196d05c Extra Win32 compatibility.
Change-Id: Ibc583aba580f4fc15c243f495ead44b2ce4c6e5e
2015-02-03 14:26:58 -08:00
Elliott Hughes
dec12b2b71 Add Google-style ReadFileToString and WriteStringToFile.
Bug: 19217569
Change-Id: I64789d3fa6777ee30a324cdf00fdc275c1230e1b
2015-02-03 12:18:11 -08:00
Yabin Cui
4a6e5a3b64 Kill HAVE_PTHREADS.
Bug: 19083585
Change-Id: Ic09eb3dd250bc5c5b63cac7998f99f5fa007f407
2015-01-27 14:23:22 -08:00
Chih-Hung Hsieh
ba8cdf99a4 Add required casts for clang/llvm -Wc++11-narrowing
system/core/include/utils/Mutex.h:134:25: error: non-constant-expression
cannot be narrowed from type 'long long' to '__kernel_time_t' (aka
'long') in initializer list [-Wc++11-narrowing]

system/core/include/utils/Mutex.h:135:26: error: non-constant-expression
cannot be narrowed from type 'long long' to 'long' in initializer list
[-Wc++11-narrowing]

Change-Id: Icb9df26aeb01617da5ab1c36987289f7c2b11954
2015-01-12 16:53:52 -08:00
Elliott Hughes
76f0a84f6a Linux always has POSIX clocks available.
pixelflinger doesn't have to run on the Mac, but the Condition
code might.

Change-Id: Ib4e9b4daa6e848ffd5742959427b172d45f08e3c
2015-01-09 16:17:46 -08:00
Jesse Hall
601424a84f Mutex: add timedLock() method
This is not available for host builds because OSX doesn't have
pthread_mutex_timedlock() or equivalent.

Bug: 18842510
Change-Id: I072e74ab1a6f770fd245828b39c5f954dda1113b
2015-01-07 08:06:51 -08:00
Dan Albert
da4f30c5b4 Merge "Remove incompatible Unicode compatibility types." 2014-12-12 02:42:30 +00:00
Chih-Hung Hsieh
c777f213b3 Use full qualified name in macros.
The ANDROID_SINGLETON_STATIC_INSTANCE is used in some files
out of the android namespace. If it does not use full qualified
names, users of this macro will need to use it inside the 'android'
namespace to avoid warnings from clang compiler.

Change-Id: Ie4d4ba2b57fdc72d0deb3b7c2326304a44a1300f
2014-12-11 11:19:57 -08:00
Elliott Hughes
8c275ffcba Fix Mac build.
Change-Id: Iae697ae257cf4b1d675e2b758dd31d5a6a71ae4d
2014-11-22 07:25:02 -08:00
Elliott Hughes
97ac0e1bb4 Kill HAVE_BIG_ENDIAN, HAVE_ENDIAN_H, and HAVE_LITTLE_ENDIAN.
Change-Id: I9e25ac9d27e95b04fb8bf7a66c619af0139d8b8f
2014-11-21 23:10:45 -08:00
Dan Albert
c59932f937 Remove incompatible Unicode compatibility types.
As well intentioned as these were, uint16_t and C++11's char16_t are
_not_ actually compatible. They are not implicitly convertible, and
they mangle differently, so they are not even ABI compatible. In our
now wonderous world of C++11, no one should be using these, so just
kill them.

Bug: 18300613
Change-Id: I06d92d7f1d937dd94a620874323d4c50eb6a31bd
2014-11-20 11:54:39 -08:00
Dan Albert
e4c649c9fc Add a pre-C++11 constexpr compatibility macro.
Needed for cases where something should be constexpr if possible, but
not being constexpr is fine if in pre-C++11 code (such as a const
static float member variable).

Bug: 18466763
Change-Id: I635d062575ba2fbc4cbe3a89f730128c404d95e1
2014-11-20 10:47:55 -08:00
Yabin Cui
266092c52d kill HAVE_POSIX_FILEMAP
Bug: 18315579
Change-Id: I0bd5fb946b12cb90e0c9c73a478df41609b8c3e2
2014-11-11 10:31:30 -08:00
Stephen Hines
f02c797256 Merge "Move winsock2.h in front of a potential windows.h include." 2014-11-09 07:24:43 +00:00
Stephen Hines
7e34121e39 Move winsock2.h in front of a potential windows.h include.
Files that included FileMap.h (possibly transitively), before including
ByteOrder.h (which pulls in winsock2.h directly), will experience a
compiler warning/error from the latest mingw headers. This happens because
the headers require that winsock2.h come before windows.h in all cases.
The simplest (and most error-proof) fix for now is to include winsock2.h
before this use of windows.h.

Change-Id: I33069e4c9962d9820d0ea5976554f89d7ff6307c
2014-11-08 19:30:05 -08:00