Commit graph

637 commits

Author SHA1 Message Date
Treehugger Robot
aa86d0ae3c Merge "Fix API for C compatibility" am: 6f3e974ab5 am: 909219ccc2
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1408797

Change-Id: I5c4a960756ba710fd1e70294f0f10414f87113bf
2020-08-26 01:28:41 +00:00
Greg Kaiser
b473061c5a Fix API for C compatibility
In https://android-review.googlesource.com/c/platform/system/core/+/1224544
when we introduced a default argument to androidSetThreadPriority(),
we broke C compatibility with this API, and with the header file
in general.

We fix this up by instead introducing a new method that takes
three arguments.  This gets this header file compiling for C again,
and keeps this particular API C compatible.

Any C++ callers of the three argument version of
androidSetThreadPriority() will need to switch to using
androidSetThreadPriorityAndPolicy().  Although since this was
a recent change, we believe there is only one such user, which
we are fixing at the same time.

Test: TreeHugger
Bug: 165009705
Merged-In: Iab0b7e6c91a8e32a17ba1b186fd0c2fe96b601e4
Change-Id: Iab0b7e6c91a8e32a17ba1b186fd0c2fe96b601e4
2020-08-24 17:29:25 +00:00
Elliott Hughes
d6e98167a5 Merge "Deprecate <utils/Debug.h>." am: 5d0eb66590 am: f2587f3698
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1402847

Change-Id: I570616eaa8976ee45ed78425f6b1ba7b78650dc3
2020-08-17 20:59:50 +00:00
Elliott Hughes
ca308a093f Merge "Don't #include <utils/Debug.h> from <utils/Flattenable.h>." am: af99e1e88a am: 80a8682fff
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1402848

Change-Id: I9afda802fb1bde38c086ba9e7b8ba995e6e4db4c
2020-08-17 20:59:22 +00:00
Elliott Hughes
5d0eb66590 Merge "Deprecate <utils/Debug.h>." 2020-08-17 20:36:10 +00:00
Elliott Hughes
884cedc770 Don't #include <utils/Debug.h> from <utils/Flattenable.h>.
It's not used, and shouldn't be used.

Also switch to `#pragma once`.

Test: treehugger
Change-Id: I464d3de1b0e1d536cea06362e6c73fddaad967d1
2020-08-17 10:14:16 -07:00
Elliott Hughes
832815151f Deprecate <utils/Debug.h>.
I stumbled across this because of the `#ifdef __cplusplus` inside an
unguarded `namespace`, but this whole file should be deprecated and
removed in favor of static_assert.

Test: treehugger
Change-Id: I2b65db67e694115e915f0cc9d762b0fd41a7d2af
2020-08-17 10:07:29 -07:00
Elliott Hughes
20fc570cd2 Merge "Add second batch of fuzzers for libutils" am: 2cfea97ba3 am: 354d814409
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1356122

Change-Id: Ia72091a216e548beb007c4f30ba3412fe54fa1b8
2020-08-10 16:10:54 +00:00
Elliott Hughes
2cfea97ba3 Merge "Add second batch of fuzzers for libutils" 2020-08-10 15:40:44 +00:00
Treehugger Robot
ba7efc63cc Merge "Add uptimeNanos to SystemClock" am: 52c8422ea1 am: c7a2225665
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1394287

Change-Id: I8dd8c3e148a011b250260a2ebc329fdeb06433a6
2020-08-08 01:37:29 +00:00
Treehugger Robot
52c8422ea1 Merge "Add uptimeNanos to SystemClock" 2020-08-08 01:04:09 +00:00
Dylan Katz
7168f2726e Add second batch of fuzzers for libutils
This adds fuzzers for:
- CallStack
- Looper
- LruCache
- Printer
- ProcessCallStack
- PropertyMap
- RWLock
- RefBase
- StopWatch.
Test: Ran each fuzzer for 10 minutes. Rough coverage est. (likely far below actual value): 10.97%

Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: I2f9f35c18b13338c282fb7f9c3ea4099ecb2c56f
2020-08-07 15:36:39 -07:00
Suprabh Shukla
a55ef96ea7 Add uptimeNanos to SystemClock
Test: system/core/libutils/SystemClock_test.cpp

Bug: 162791194
Change-Id: I0e3ea2004146eb7442c89bb35a9f3a2171d9c4b8
2020-08-07 14:36:07 -07:00
Steven Moreland
f1c0be76ab Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8 am: d05ecb8d9d am: dc99a094dd am: 64b312bbd8 am: 0cb14f1fe7 am: ce44c8ac3c
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: I6fb2a6370b202cbe476aee558e09c702605d8328
2020-08-04 23:38:00 +00:00
Steven Moreland
ce44c8ac3c Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8 am: d05ecb8d9d am: dc99a094dd am: 64b312bbd8 am: 0cb14f1fe7
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: I1cb83a4a22e205dddd10536f61392215d5cb33dc
2020-08-04 23:19:46 +00:00
Steven Moreland
64b312bbd8 Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8 am: d05ecb8d9d am: dc99a094dd
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: I79dcbb310a2515e7f17ad2ebbb0367070084dab2
2020-08-04 22:46:49 +00:00
Steven Moreland
dc99a094dd Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8 am: d05ecb8d9d
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: I816b8858c69e6481299f942401a16b5b39cd8b69
2020-08-04 22:21:36 +00:00
Steven Moreland
d05ecb8d9d Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: Ifa0692e4966e78f4e180a2efc53db991177b6006
2020-08-04 22:03:55 +00:00
Steven Moreland
d8801aaad8 Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: Id247c7079c146da8eaf52f098027d5daa25ce8d8
2020-08-04 21:37:54 +00:00
Steven Moreland
a03d37d542 Merge "libutils: check vsnprintf error" into oc-dev 2020-08-04 21:20:36 +00:00
TreeHugger Robot
cf6c14c850 Merge "Fail explicitly on length overflow." into oc-dev am: ea8d38e77f am: cf91151364 am: 84dcff4c6b
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619803

Change-Id: Ie7b7a57f55ead23f8d382ac98eb5087a2c614b1b
2020-07-31 20:24:42 +00:00
TreeHugger Robot
84dcff4c6b Merge "Fail explicitly on length overflow." into oc-dev am: ea8d38e77f am: cf91151364
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619803

Change-Id: Idb480f2a4dc1aa0d929e17e7e568a9c1b05c8489
2020-07-31 20:03:44 +00:00
TreeHugger Robot
cf91151364 Merge "Fail explicitly on length overflow." into oc-dev am: ea8d38e77f
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619803

Change-Id: I9a6def9ff590fdadb457e9a011df3532829d23f4
2020-07-31 19:45:35 +00:00
TreeHugger Robot
ea8d38e77f Merge "Fail explicitly on length overflow." into oc-dev 2020-07-31 19:24:50 +00:00
TreeHugger Robot
30a74852b0 Merge "Fail explicitly on length overflow." into qt-dev 2020-07-30 21:21:49 +00:00
Steven Moreland
ee22384c54 libutils: check vsnprintf error
For encoding errors, this function will return a negative value which
causes problems down the line. Check for an error and return. Also,
integer overflows are guarded.

Bug: 161894517
Test: fuzzer test case
Change-Id: Ia85067d4258bde4b875c832d6223db5dd26b8838
Merged-In: Ia85067d4258bde4b875c832d6223db5dd26b8838
2020-07-30 17:29:34 +00:00
Treehugger Robot
3105cca029 Merge "Update language to comply with Android's inclusive language guidance" am: 98ea1340fb am: b939c5602c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1373460

Change-Id: Id3fd33f2d61182ab18e87d80f0adabca855ffb80
2020-07-29 20:55:31 +00:00
Dan Albert
ac4500e67d Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: http://b/161896447
Test: None
Change-Id: I9e5a37a20012b2f7a8eac55701df03f7b7a9ab6c
2020-07-28 15:58:25 -07:00
Michael Wright
ec8ff6eed3 Merge "Soften BitSet class comment." am: 2ea91cfe76 am: 009d58d8da
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1360510

Change-Id: I3f6493c151e4b75be52cf3e2dbda1db94c9642b6
2020-07-16 13:00:28 +00:00
Michael Wright
f32317c869 Soften BitSet class comment.
std::bitset<> doesn't have exact replacements for all of the
functionality of BitSet32/64, so there are still places we want to use
these classes.

Bug: 160010896
Test: test BitSet_test.cpp
Change-Id: Ica59a138e014d82139fb6dcea0597a207faecc2a
2020-07-16 00:04:20 +00:00
Steven Moreland
80c46b0541 String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61 am: 9be245c3f0 am: 64fb5012b8 am: 4e27b6992b am: 26b81f59d2 am: 8367a666b5
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: Ic25dca55b553b062edc4ced44ddef68b96428906
2020-07-14 17:24:42 +00:00
Victor Khimenko
add3b3a137 Merge "Make libbacktrace buildable for native_bridge" into rvc-dev 2020-07-14 17:18:34 +00:00
Steven Moreland
8367a666b5 String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61 am: 9be245c3f0 am: 64fb5012b8 am: 4e27b6992b am: 26b81f59d2
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: Ib4704bc8a733ace56e7998b7bad5a6c5638900ad
2020-07-14 17:03:30 +00:00
Steven Moreland
3619489de6 Merge "String8: explicit int -> char cast." 2020-07-14 16:30:42 +00:00
Steven Moreland
4e27b6992b String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61 am: 9be245c3f0 am: 64fb5012b8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I03057c052a24f205c78ee600178d45e0cd51a3c1
2020-07-14 16:29:09 +00:00
Steven Moreland
64fb5012b8 String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61 am: 9be245c3f0
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I3ab9771d898eea0158acfd07fbe5a2f4b7dad883
2020-07-14 16:12:53 +00:00
Steven Moreland
9be245c3f0 String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I22f6b8299b4b77be31859a10b14efe01b297d531
2020-07-14 15:51:29 +00:00
Steven Moreland
107f18cb61 String16::remove - avoid overflow am: 4048e49956
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I4dedf81e3471473e589a858e14d7a9ae5f91b3d9
2020-07-14 15:37:25 +00:00
Steven Moreland
fdbc565dd5 String8: explicit int -> char cast.
Since tolower/toupper take and return integer arguments, ascii chars in
the extended range will be converted from positive int values to
negative char values. In order to silence an error here, which was added
recently with integer sanitization here, casting explicitly.

Fixes: 160831549
Test: w/ libutils_fuzz_string8
Change-Id: Iedcd6643f95f84ce662a80e38931d918a200f508
2020-07-13 23:33:25 +00:00
Michael Wright
71f4494bd1 Merge "Cast away signedness of built-ins in BitSet." 2020-07-13 15:45:40 +00:00
Michael Wright
23e1363d55 Cast away signedness of built-ins in BitSet.
Most of the built-in functions return signed values but BitSet deals
only in unsigned values. We can safely cast these away though as they're
always indices, which can't be negative.

Bug: 160010896
Test: atest inputflinger_tests, atest libinput_tests
Change-Id: I6e0b33972fabcd41ad1c269ea0e2a07b13b33c12
2020-07-12 01:56:58 +01:00
Victor Khimenko
fb60e6c9ae Make libbacktrace buildable for native_bridge
Bug: http://b/153609531

Test: m -j64 libbacktrace.native_bridge

Change-Id: I2b8a881b4e952f3b68dbcaeb14f147a6d955b406
Merged-In: I2b8a881b4e952f3b68dbcaeb14f147a6d955b406
2020-07-10 20:13:23 +02:00
Yo Chiang
5b028bab2a Move SingletonTest back to libutils_test
Use the new "data_libs:" to specify test library dependency. This is
like "data:" and it treats compiled libraries as test data files.
The result is libutils_test_singleton{1,2} is picked up by libutils_test
and installed next to the test binary.

Mark the test libs libutils_test_singleton{1,2} as uninstallable. This
prevents installing libutils_test_singleton{1,2} directly and only
permits installing via "data_libs:".

```
$ m libutils_test
testcases
└── libutils_test
    ├── arm
    │   ├── libutils_test
    │   ├── libutils_test_singleton1.so
    │   └── libutils_test_singleton2.so
    ├── arm64
    │   ├── libutils_test
    │   ├── libutils_test_singleton1.so
    │   └── libutils_test_singleton2.so
    └── libutils_test.config
```

Bug: 124838889
Test: atest libutils_test
Change-Id: I432135e128fc9eedb1b8c18a331957e271d8b0f0
2020-07-10 19:34:53 +08:00
Steven Moreland
9c832028c1 libutils: integer sanitization
For sanity.

Fixes: 160342252
Test: manually introduce overflow for "ubsan: mul-overflow"
Change-Id: I292039eaef24582f05dd9f0fef011f0ece8364ed
2020-07-07 22:37:07 +00:00
Victor Khimenko
7428c52ef2 Make libbacktrace buildable for native_bridge
Bug: http://b/153609531

Test: m -j64 libbacktrace.native_bridge

Change-Id: I2b8a881b4e952f3b68dbcaeb14f147a6d955b406
2020-06-18 22:02:46 +02:00
Christopher Ferris
4d14303653 Fail explicitly on length overflow.
Instead of aborting when FileMap::create detects an overflow, detect the
overflow directly and fail the call.

Bug: 156997193

Test: Ran unit tests, including new unit test that aborted before.
Change-Id: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
Merged-In: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
(cherry picked from commit 68604b9c29)
2020-06-04 11:05:18 -07:00
Christopher Ferris
f846413e62 Fail explicitly on length overflow.
Instead of aborting when FileMap::create detects an overflow, detect the
overflow directly and fail the call.

Bug: 156997193

Test: Ran unit tests, including new unit test that aborted before.
Change-Id: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
Merged-In: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
(cherry picked from commit 68604b9c29)
2020-05-28 18:38:18 -07:00
Christopher Ferris
bff51b88aa Fail explicitly on length overflow.
Instead of aborting when FileMap::create detects an overflow, detect the
overflow directly and fail the call.

Bug: 156997193

Test: Ran unit tests, including new unit test that aborted before.
Merged-In: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
Change-Id: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
(cherry picked from commit 68604b9c29)
2020-05-28 15:46:51 -07:00
Steven Moreland
4048e49956 String16::remove - avoid overflow
Bug: 156999009
Test: libutils_test (cases added)
Change-Id: Iad46d95d9848928ba81000090b2fe9aec1e5eaac
Merged-In: Iad46d95d9848928ba81000090b2fe9aec1e5eaac
(cherry picked from commit f251c1c581)
(cherry picked from commit 9a9c8910e9296c9dc8d79c37f589895f5a2a836c)
2020-05-28 20:45:55 +00:00
Elliott Hughes
842e1cc17e Make systemTime() abort on bad input.
There's no CHECK in libutils, sadly.

Bug: http://b/157167405
Test: treehugger
Change-Id: I1532bf80ba7fdafad016610be3c782b547417126
2020-05-27 15:31:55 -07:00