summaryrefslogtreecommitdiffstats
path: root/libutils
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'cm-13.0' of https://github.com/CyanogenMod/android_system_core ↵Wolfgang Wiedmeyer2016-12-124-16/+51
|\ | | | | | | into replicant-6.0
| * Merge tag 'android-6.0.1_r66' into HEADJessica Wagantall2016-09-073-16/+43
| |\ | | | | | | | | | | | | | | | Android 6.0.1 release 66 Change-Id: I5ccc6e68283e30b8d0419eb7512c7183e58ec5ed
| | * libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8Sergio Giro2016-07-213-16/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 c4966a363e46d2e1074d1a365e232af0dcedd6a1)
| * | libutils: fix deadlock in elapsedRealtimeNanoScott Mertz2016-08-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If n > 2 threads all lock the mutex awaiting the clock method to be set, the 1st thread will first set the method and unlock. The 2nd thread will then take the mutex, but never unlock because the clock_method has already been updated by the 1st thread. This causes a deadlock for threads 3-n. Solution is to ensure the calling thread always unlocks the mutex if it has previously locked it. Log: "main" prio=5 tid=1 Native | group="main" sCount=1 dsCount=0 obj=0x733313b0 self=0xb4cf6500 | sysTid=12786 nice=0 cgrp=default sched=0/0 handle=0xb6f86b44 | state=S schedstat=( 41990410 32985836 80 ) utm=3 stm=1 core=2 HZ=100 | stack=0xbe5fb000-0xbe5fd000 stackSize=8MB | held mutexes= native: #00 pc 00017638 /system/lib/libc.so (syscall+28) native: #01 pc 0003ffa5 /system/lib/libc.so (_ZL33__pthread_mutex_lock_with_timeoutP24pthread_mutex_internal_tPK8timespeci+504) native: #02 pc 000400a9 /system/lib/libc.so (pthread_mutex_lock+26) native: #03 pc 0000fa01 /system/lib/libutils.so (_ZN7android19elapsedRealtimeNanoEv+16) native: #04 pc 0000fb1f /system/lib/libutils.so (_ZN7android15elapsedRealtimeEv+2) native: #05 pc 00214d1d /data/dalvik-cache/arm/system@framework@boot.oat (Java_android_os_SystemClock_elapsedRealtime__+72) "Thread-6372" prio=5 tid=9 Native | group="main" sCount=1 dsCount=0 obj=0x32c05120 self=0xacb58100 | sysTid=12829 nice=10 cgrp=bg_non_interactive sched=0/0 handle=0xb38c3930 | state=S schedstat=( 869427 8219115 17 ) utm=0 stm=0 core=2 HZ=100 | stack=0xb37c1000-0xb37c3000 stackSize=1038KB | held mutexes= native: #00 pc 00017638 /system/lib/libc.so (syscall+28) native: #01 pc 0003ffa5 /system/lib/libc.so (_ZL33__pthread_mutex_lock_with_timeoutP24pthread_mutex_internal_tPK8timespeci+504) native: #02 pc 000400a9 /system/lib/libc.so (pthread_mutex_lock+26) native: #03 pc 0000fa01 /system/lib/libutils.so (_ZN7android19elapsedRealtimeNanoEv+16) native: #04 pc 0000fb1f /system/lib/libutils.so (_ZN7android15elapsedRealtimeEv+2) native: #05 pc 00214d1d /data/dalvik-cache/arm/system@framework@boot.oat (Java_android_os_SystemClock_elapsedRealtime__+72) HAM-1470 Change-Id: I41874d2b0ea034a35a74da030398231089c15cde
* | | Use readdir instead of readdir_r.Elliott Hughes2016-12-091-10/+3
|/ / | | | | | | | | | | | | http://elliotth.blogspot.com/2012/10/how-not-to-use-readdirr3.html Test: boots. Change-Id: If75532e24fe4d17743bf8e8c9590156dee378a63
* | Merge tag 'android-6.0.0_r26' into cm-13.0Ricardo Cerqueira2015-11-051-0/+2
|\ \ | |/ | | | | | | | | Android 6.0.0 release 26 Change-Id: I93d1e3767cbacab2b18cff360065c91b9eaf1d96
| * resolved conflicts for 832a0d1c to mnc-devBrian Carlstrom2015-09-191-0/+2
| |\ | | | | | | | | | Change-Id: Ic46ee60de7bc500f4e1d5fe841524db80918a8d9
| | * resolved conflicts for cf676a86 to lmp-mr1-ub-devBrian Carlstrom2015-09-193-23/+139
| | |\ | | | | | | | | | | | | Change-Id: Ifd9a44777a472ae893f894391bff7ef81456d92c
| | | * libutils: Fix integer overflows in VectorImpl.Narayan Kamath2015-09-093-23/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use external/safe-iop to check for overflows on arithmetic operations. Also remove an unnecessary copy of Vector/SharedBuffer from codeflinger and use the copy from libutils instead. Note that some of the unit tests are somewhat useless due to test-runner limitations : gtest's ability to filter on abort message doesn't work when combined with messages formatted by android's logging system. bug: 22953624 (cherry picked from commit c609c31fb56ae434caa2d0153cd0a2f74a715071) Change-Id: I61644633db6b54fa230683615de9724f7fabf6fb
| | * | resolved conflicts for merge of 7c327194 to lmp-mr1-ub-devBart Sears2015-08-263-1/+87
| | |\ \ | | | |/ | | | | | | | | Change-Id: I236367bd60046ba06669cbcdae81184f9d0a74c7
| | | * libutils: fix overflow in SharedBuffer [DO NOT MERGE]Sergio Giro2015-08-253-1/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See https://code.google.com/p/android/issues/detail?id=181910 Bug: 22952485 (cherry picked from commit 66b6eb9490beeeabc804d790c1c4060ce047afd4) Change-Id: Ic71dd0025b9a7588c4f3bb1c7be1bd13d2ff5105
| * | | libutils: Fix integer overflows in VectorImpl.Narayan Kamath2015-09-024-23/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use external/safe-iop to check for overflows on arithmetic operations. Also remove an unnecessary copy of Vector/SharedBuffer from codeflinger and use the copy from libutils instead. Note that some of the unit tests are somewhat useless due to test-runner limitations : gtest's ability to filter on abort message doesn't work when combined with messages formatted by android's logging system. bug: 22953624 Change-Id: I46b1ae8ca1f3a010be13aca36a091e76a97a7b70
* | | | Merge tag 'android-6.0.0_r5' into cm-13.0Ricardo Cerqueira2015-11-034-23/+145
|\ \ \ \ | | | | | | | | | | | | | | | Android 6.0.0 release 5
| * | | | libutils: Fix integer overflows in VectorImpl.Narayan Kamath2015-09-284-23/+145
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use external/safe-iop to check for overflows on arithmetic operations. Also remove an unnecessary copy of Vector/SharedBuffer from codeflinger and use the copy from libutils instead. Note that some of the unit tests are somewhat useless due to test-runner limitations : gtest's ability to filter on abort message doesn't work when combined with messages formatted by android's logging system. bug: 22953624 Change-Id: I46b1ae8ca1f3a010be13aca36a091e76a97a7b70
* | | | libutils: Improve support for POSIX timersSteve Kondik2015-10-291-17/+42
|/ / / | | | | | | | | | | | | | | | * Don't repeatedly try to open nonexistent devices where possible. Change-Id: Id1f18d05943a66978d430556fa16ed761e8e464b
* | | libutils: fix overflow in SharedBuffer [DO NOT MERGE]Sergio Giro2015-08-253-1/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See https://code.google.com/p/android/issues/detail?id=181910 Bug: 22952485 (cherry picked from commit 66b6eb9490beeeabc804d790c1c4060ce047afd4) Change-Id: I363f49b5b3c6b7b3ac08cba2c14d72c431588c5a
* | | am fc5fdc85: am e45d96d6: am 19398a71: am d34846b7: am cd407a17: am ↵Abhishek Arya2015-08-211-0/+3
|\ \ \ | |/ / | | | | | | | | | | | | | | | e0dce90b: Fix compile failure after rIfe1dc0791040150132bea6884f1e6c8d31972d1b * commit 'fc5fdc85683f87c42d5ce7bcee4e2b70ef0acdd0': Fix compile failure after rIfe1dc0791040150132bea6884f1e6c8d31972d1b
| * | am e45d96d6: am 19398a71: am d34846b7: am cd407a17: am e0dce90b: Fix compile ↵Abhishek Arya2015-08-211-0/+3
| |\ \ | | |/ | | | | | | | | | | | | | | | failure after rIfe1dc0791040150132bea6884f1e6c8d31972d1b * commit 'e45d96d6bf592f0ae20bb021ea529acc94e0cb55': Fix compile failure after rIfe1dc0791040150132bea6884f1e6c8d31972d1b
| | * am cd407a17: am e0dce90b: Fix compile failure after ↵Abhishek Arya2015-08-211-0/+3
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | rIfe1dc0791040150132bea6884f1e6c8d31972d1b * commit 'cd407a17fe326f3e18866ddddb1c747b06a45fc0': Fix compile failure after rIfe1dc0791040150132bea6884f1e6c8d31972d1b
| | | * am e0dce90b: Fix compile failure after ↵Abhishek Arya2015-08-211-0/+3
| | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rIfe1dc0791040150132bea6884f1e6c8d31972d1b * commit 'e0dce90b0de2b2b7c2baae8035f810a55526effb': Fix compile failure after rIfe1dc0791040150132bea6884f1e6c8d31972d1b
| | | | * Fix compile failure after rIfe1dc0791040150132bea6884f1e6c8d31972d1bAbhishek Arya2015-08-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Bug: 23290056 Change-Id: If6e22b0159de6635a8ca5305895b7718f15becc7
| * | | | am e97682be: am a1a22b57: am e67b5848: am 4956c0fe: am 5b85b1d4: libutils: ↵Sergio Giro2015-08-201-0/+3
| |\ \ \ \ | | |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | fix overflow in String8::allocFromUTF8 * commit 'e97682be0634fe773f70097bc518e5d034efe8f7': libutils: fix overflow in String8::allocFromUTF8
| | * | | am 4956c0fe: am 5b85b1d4: libutils: fix overflow in String8::allocFromUTF8Sergio Giro2015-08-201-0/+3
| | |\ \ \ | | | |/ / | | | | | | | | | | | | | | | * commit '4956c0fe1e582a8497aff34a41aeb8bf4748eef0': libutils: fix overflow in String8::allocFromUTF8
| | | * | am 5b85b1d4: libutils: fix overflow in String8::allocFromUTF8Sergio Giro2015-08-201-0/+3
| | | |\ \ | | | | |/ | | | | | | | | | | | | | | | * commit '5b85b1d40d619c2064d321364f212ebfeb6ba185': libutils: fix overflow in String8::allocFromUTF8
| | | | * libutils: fix overflow in String8::allocFromUTF8Sergio Giro2015-08-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch contributed in: https://code.google.com/p/android/issues/detail?id=182908 Bug: 23290056 (cherry picked from commit 4eeacbeec0ae66e9d9395abbf83666709f2e11e3) Change-Id: Ife1dc0791040150132bea6884f1e6c8d31972d1b (cherry picked from commit ebabef275283f771151ec93c17469374b789b2c8)
* | | | | libutils: fix overflow in String8::allocFromUTF8Sergio Giro2015-08-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch contributed in: https://code.google.com/p/android/issues/detail?id=182908 Bug: 23290056 (cherry picked from commit 4eeacbeec0ae66e9d9395abbf83666709f2e11e3) Change-Id: Ife1dc0791040150132bea6884f1e6c8d31972d1b
* | | | | Merge "Work around spurious epoll notifications." into mnc-devJeff Brown2015-05-301-0/+5
|\ \ \ \ \
| * | | | | Work around spurious epoll notifications.Jeff Brown2015-05-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes it seems like we can get into a situation where we are unable to remove an fd from the epoll set but it keeps sending us events anyhow. Defensively rebuild the epoll set in this case to prevent us from spinning forever. Bug: 21271428 Change-Id: I5607e565f2e12460d7113a1f62a70d38d334e271
* | | | | | Adding a build id check to blob cache.Michael Lentine2015-05-182-7/+17
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | Move LinearAlloc to libhwuiJohn Reck2015-04-232-228/+0
| | | | | | | | | | | | | | | | | | | | Change-Id: I83a70959ed0dcab2237faaf1dddc02b5eb0363c9
* | | | | am 8d2cd035: am 2ddb9cb1: am ed43be39: Merge "Remove ↵Elliott Hughes2015-04-021-1/+0
|\ \ \ \ \ | |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | LOCAL_ADDITIONAL_DEPENDENCIES in cases where it\'s not needed." * commit '8d2cd03547c76f6c670b33d4fe6d44b646c14b45': Remove LOCAL_ADDITIONAL_DEPENDENCIES in cases where it's not needed.
| * | | | Remove LOCAL_ADDITIONAL_DEPENDENCIES in cases where it's not needed.Elliott Hughes2015-04-021-1/+0
| | | | | | | | | | | | | | | | | | | | Change-Id: I720b8ef1050da45a7833adef8219b6acb2cf3a38
| * | | | Revert "Revert "Create libbase.""Dan Albert2015-03-166-352/+0
| | | | | | | | | | | | | | | | | | | | This reverts commit a7870d88167f619e758b5bcd15b410d16da7c16b.
* | | | | Use eventfd instead of pipe in Looper.Tim Kilbourn2015-03-271-32/+14
| | | | | | | | | | | | | | | | | | | | | | | | | Bug: 19933224 Change-Id: I6611e918db960bbb0e74f8308e10bdf79510b899
* | | | | Revert "Revert "Create libbase.""Dan Albert2015-03-166-352/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit a7870d88167f619e758b5bcd15b410d16da7c16b. (cherry picked from commit c007bc3856a4cf86b8f610eb045f26a9dedc2894)
* | | | | am 90a968f0: am dd581695: Merge "Revert "Create libbase.""Nicolas Geoffray2015-03-166-0/+352
|\ \ \ \ \ | |/ / / / | | | | | | | | | | | | | | | * commit '90a968f0e3fb903aad41f6689c337a7e4a8d5c7b': Revert "Create libbase."
| * | | | Revert "Create libbase."Nicolas Geoffray2015-03-166-0/+352
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Breaks internal master. This reverts commit 98ff77204cef9bb8f0f27420833233622060a09e. Change-Id: I18dc6021cb43efff8aa88486c2d980dc2b8eedba
* | | | | am 517f65da: am a68c8148: Merge "Create libbase."Dan Albert2015-03-156-352/+0
|\ \ \ \ \ | |/ / / / | | | | | | | | | | | | | | | * commit '517f65daef177d06d7835300a1c23ce3409c0643': Create libbase.
| * | | | Create libbase.Dan Albert2015-03-146-352/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move StringPrintf and the string based file I/O from libutils to libbase. Change-Id: I0297a6063874b9d92100e0dd5123fddfbda932fe
* | | | | Fix issues related to removing Looper callbacks after close.Jeff Brown2015-03-121-32/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | Fixed subtle bugs related to file descriptor recycling.Jeff Brown2015-03-111-11/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | Rename Looper::isIdling() to isPolling() to resolve confusion.Jeff Brown2015-03-111-5/+5
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | Remove useless refCounting from FileMap.Narayan Kamath2015-02-232-11/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | Merge "Remove reference to NOT_USING_KLIBC and cygwin."Narayan Kamath2015-02-201-14/+1
|\ \ \ \
| * | | | Remove reference to NOT_USING_KLIBC and cygwin.Narayan Kamath2015-02-191-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reference to NOT_USING_KLIBC appears to be the only one in our codebase. This change also removes some cygwin specific retry logic - all other supported platforms in this section of the code should support mapping at an offset. Note that i've reversed the sense of the check, we always sysconf since that's recommended practice. Change-Id: Ib985fb665193d7a07a282f7092cd77c0bc508a66
* | | | | Fix the WriteStringToFile overload that takes mode/owner/group.Elliott Hughes2015-02-172-2/+31
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The actual bug is == instead of !=, but the real cause was me trying to be too clever. This patch switches to much simpler code, and -- since the intended use of this code is security anyway -- adds logging if anything goes wrong. Bug: 19361774 Change-Id: If2af07d31a5002f9010b838247b691f6b28bdfb1
* | | | Clean up reading and writing in init.Elliott Hughes2015-02-062-24/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | Fix Windows build.Elliott Hughes2015-02-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Only two days in, and I'm already really regretting putting this code somewhere that builds for Mac OS and Windows... Change-Id: I576ee4a9e647e10dc2d47c7e1e38aedee2bf404c
* | | | Add a WriteStringToFile overload that cares about permissions.Elliott Hughes2015-02-041-8/+35
| | | | | | | | | | | | | | | | Change-Id: I857a80b61768d4e9610bdd149eff2d9d8e48d2c0
* | | | Add Google-style StringPrintf.Elliott Hughes2015-02-034-0/+137
| | | | | | | | | | | | | | | | Change-Id: If333c28b8ed047346a2dd85e591c4bedbab874cc