The old implementation was unnecessarily complex, and using the wrong ioctl
for point-to-point destination addresses.
Bug: http://b/27313259
Change-Id: I9cabd17e414ce42b115037a3f828d79843f604f9
clang depends on memcpy where src and dst are the same to actually
work. Even though this is, technically, undefined behavior,
clang is not going to change. Add a test to verify this assumption
holds true for android devices.
Change-Id: Ib575af3c14e705bb62c18fad7d57e1cc0d242899
In order to enforce this constraint:
The pointer returned if the allocation succeeds shall be suitably
aligned so that it may be assigned to a pointer to any type of object
and then used to access such an object in the space allocated.
Force all allocations on 32 bit systems to have 8 byte alignment,
and all allocations on 64 bit systems to have 16 byte alignment.
Add a test to verify that the allocator returns the correct alignments.
Bug: 26739265
Change-Id: I9af53279617408676b94e4ec6481b3ed7ffafc6a
Found by passing a bad regular expression to the Google benchmark
code (https://github.com/google/benchmark).
Change-Id: I475db71c25706bbf02091b754acabe8254062f3a
POSIX lets us return null and set errno, but that would be annoying and
surprising.
Bug: http://b/27101951
Change-Id: I320a8a14884abb806a8d30e3e6cf1ede28b49335
It turns out we don't have any bugs here, but glibc does. Found while
chasing down a toybox failure I saw on the host, but we may as well
add the test in case we ever screw up here in future.
Change-Id: Ib8dd227ed3b742dc4dab8c09dc08e6ea9a35c807
This is a common thing for people to want to do, snprintf requires
a lot of stack for itself, and PTHREAD_STACK_MIN should be usable
for realistic code.
Change-Id: Ib09cfb4e0beec1c69ee0944c3ea4c5d03a94c491
Our fopen/freopen/tmpfile are already always O_LARGEFILE, but let's add
the aliases for _LARGEFILE_SOURCE compatibility.
Bug: http://b/24807045
Change-Id: I5d99b3ef3c9f27ce70f13313f6a92e96c7f21f80
The interface name wasn't being nul-terminated for the ioctl. Also clean up
the code a bit to give more useful diagnostics on failure.
Bug: http://b/26887941
Change-Id: I30c6bdc1a32733971a27ed1fb7db9d8239b6262b
This also lets us test the EOVERFLOW behavior, which pointed out that the
fgetpos/fsetpos return on failure has always been wrong...
Bug: http://b/24807045
Change-Id: I35273eb07c8c9155af858adb27569983397580b6
This has been requested a few times over the years. This is basically
a very late rebase of https://android-review.googlesource.com/45470
which was abandoned years ago. One addition is that this version has
_FILE_OFFSET_BITS=64 support.
POSIX puts this in <unistd.h>. glibc also has it in <fcntl.h>.
Bug: http://b/13077650
Change-Id: I5862b1dc326e326c01ad92438ecc1578d19ba739
Broke the build. There's no such file as bionic_sdk_version.h anywhere in the tree.
This reverts commit 892b61d340.
Change-Id: Iec3f4588edfb1d1524bb5f16451fd05dc6ebe44a
Posix standards says sem_wait is interruptible by the delivery
of a signal. To keep compatiblity with old apps, only fix that
in newer sdk versions.
Bug: 26743454
Change-Id: I924cbb436658e3e0f397c922d866ece99b8241a3
This test didn't catch anything, but it does ensure that we exercise
the "lots of files" case.
Bug: http://b/26747402
Change-Id: I6c51c6436029572a49190d509f131eb93b808652
We've seen it take 1146us on Nexus 9 (which did have exceptionally slow
system calls).
Bug: http://b/26724042
Change-Id: I263b7e1267d58fe4a6528403d03e5b245fdcd528
dlclose used to unmap the part of the reserved region
for ANDROID_DLEXT_RESERVED_ADDRESS that was neccessary
to map PT_LOAD segments. With this change dlclose
replaces mapped PT_LOAD segments with a PROT_NONE,
MAP_ANONYMOUS | MAP_NORESERVE.
Previously caller was unmapping the reserved region after
the failed dlclose which led to race condition when someone
else reused the region freed by dlclose but before the unmap
by the chromium code.
Bug: http://code.google.com/p/chromium/issues/detail?id=568880
Change-Id: I0f5eaa2bf6641f83dde469b631c518482acc59a2
Roll our own version of zipalign so that we can break the dependency
on the build tools zipalign. This breaks the transitive dependency
on androidfw so that building bionic unit tests in brillo works again.
Also modify the DlExtTest.ExtInfoUseFdWithOffset test so it dynamically
gets the offset of the shared library inside of the zip instead of
hard-coding the value.
Bug: 25446938
Change-Id: Idfb5d3089960a94eefa2c76e03da1ad2f4d7fb2f
BSD doesn't invalidate the fd stored in struct FILE, which can make
it possible (via fileno(3), for example), to perform operations on
an fd you didn't intend to (rather than just failing with EBADF).
Fixing this makes the code slightly simpler anyway, and might help
catch bad code before it ships.
Bug: http://stackoverflow.com/questions/10816837/fclose-works-differently-on-android-and-linux
Change-Id: I9db74584038229499197a2695c70b58ed0372a87
This is just a subset of the recently-implemented getifaddrs(3), though if
we want to handle interfaces (such as "rmnet_*") that don't have an address,
we need to either expose ifaddrs_storage and keep track of which interfaces
we've already seen (which is pretty messy), or refactor the netlink code so
we can reuse it and just extract the information we need for if_nameindex(3).
This patch goes the latter route.
Also clean up if_nametoindex(3) and if_indextoname(3).
Change-Id: I5ffc5df0bab62286cdda2e7af06f032c767119a8
This adds the following two checks:
* getifaddrs sees the same list of interfaces as /sys/class/net.
* IPv4 addresses we get from netdevice(7) agrees with results from
getifaddrs.
Change-Id: I2f6d79d0b5cde6d98a0f671d1623b6b2bc75b60f
The select_smoke and pselect_smoke test can fail if STDIN has data ready
to be read. The easiest way to see the failure is to type on the command
line while running the tests.
To avoid this, allow the return value to be 2 or 3 and check which fds
are ready to be read.
Change-Id: Iafba332c5f3ed1943e3d34501f123dd45f06a8c4
Add a way to turn fortify off for the files that test fortify functions.
This method involves simply compiling the same file with fortify off and
changing the test name slightly.
It's not very pretty, and it assumes that only these few files test
functions that can be fortified.
Bug: 15195631
Change-Id: Iba9db1d508b7d28a1d6968019cb70fe08864827b