Commit graph

92 commits

Author SHA1 Message Date
Elliott Hughes
cccfe1e17c Reimplement clock(3) and switch to OpenBSD time(3).
The new implementation is a better approximation to the processor time used
by the process because it's actually based on resource usage rather than just
elapsed wall clock time.

Change-Id: I9e13b69c1d3048cadf0eb9dec1e3ebc78225596a
2014-03-11 13:37:11 -07:00
Elliott Hughes
aedb00d04e Switch to upstream alarm(3).
The only way the setitimer call can fail is if the unsigned number of seconds is
too large to fit in the kernel's signed number of seconds. If you schedule a
68-year alarm, glibc will fail by returning 0 and BSD will fail by returning -1.

Change-Id: Ic3721b01428f5402d99f31fd7f2ba2cc58805607
2014-03-04 00:58:31 +00:00
Elliott Hughes
1e4378ea06 Switch to current OpenBSD system.c.
Change-Id: Ie2df60f0d55dca69149ffe064f10183411407987
2014-02-25 15:19:26 -08:00
Elliott Hughes
0133944b09 Clean up our OpenBSD usage.
Also undo some of the mess where we have OpenBSD <stdio.h> but a mix of
different BSD's implementations.

In this first pass, I've only moved easy OpenBSD stuff.

Change-Id: Iae67b02cde6dba9d8d06fedeb53efbfdac0a8cf6
2014-02-21 14:30:18 -08:00
Elliott Hughes
d278b828fe Switch to current upstream getopt_long.
Change-Id: I4c646dcb8be9e88dd54d069a03bbc5fbfd92de03
2013-06-25 14:56:17 -07:00
Elliott Hughes
61e699a133 Clean up abort.
* A dlmalloc usage error shouldn't call abort(3) because we want to
  cause a SIGSEGV by writing the address dlmalloc didn't like to an
  address the kernel won't like, so that debuggerd will dump the
  memory around the address that upset dlmalloc.

* Switch to the simpler FreeBSD/NetBSD style of registering stdio
  cleanup. Hopefully this will let us simplify more of the stdio
  implementation.

* Clear the stdio cleanup handler before we abort because of a dlmalloc
  corruption error. This fixes the reported bug, where we'd hang inside
  dlmalloc because the stdio cleanup reentered dlmalloc.

Bug: 9301265
Change-Id: Ief31b389455d6876e5a68f0f5429567d37277dbc
2013-06-12 14:14:53 -07:00
Ben Cheng
7e6ce1a3c5 Fix abort(3) to raise SIGABRT rather than causing SIGSEGV.
tgkill() needs the .save stack unwinding directive to get the complete
stack trace.

BUG: https://code.google.com/p/android/issues/detail?id=16672

Change-Id: Ifb447dca2147a592c48baf32769dfc175d8aea72
2013-06-10 17:17:46 -07:00
Elliott Hughes
6b3f49a537 Upgrade to current NetBSD popen/pclose.
This gets us back to using vfork now our ARM vfork assembler stub is
fixed, and adds the missing thread safety for the 'pidlist'.

Bug: 5335385
Change-Id: Ib08bfa65b2cb9fa695717aae629ea14816bf988d
2013-03-06 16:20:55 -08:00
Elliott Hughes
e4ccf5a138 __progname should be const char*, not char*.
Change-Id: I8e846872c30a712fbc05c8da59ffa1cec1be31a4
2013-02-07 12:06:44 -08:00
Elliott Hughes
ab44f52202 More upstream NetBSD upgrades.
Change-Id: Idb781d37de3b05585271d7d258ecffd5ba87d0b8
2012-10-23 16:05:09 -07:00
Elliott Hughes
a89864a20b Move non-upstream code into the libc/bionic directory.
I'll need at least one more pass, because there's some upstream code
lurking in libc/bionic, but this is still a step in the right direction.

Change-Id: I55927315972da8327ae01c5240ed587db17e8462
2012-10-01 17:35:49 -07:00
Irina Tirdea
b5f053b5a7 Make strerror(3) and strsignal(3) thread-safe, and add psignal(3) and psiginfo(3).
Change-Id: I426109db25e907980d6cb3a7a695796e45783b78
2012-09-13 15:18:21 -07:00
Elliott Hughes
04a83a48ed Enhance getcwd(3) to handle NULL like glibc.
Bug: http://code.google.com/p/android/issues/detail?id=36085
Change-Id: I960a1b585887eb66176c61d29c5c61c239a4003f
2012-08-16 15:59:12 -07:00
Elliott Hughes
cc213f871b Switch to the current NetBSD regex implementation.
Change-Id: If32b28dd85d6a7ab8957ab81d19fa4c0de9499d5
2012-08-15 15:39:11 -07:00
Elliott Hughes
3d2d448af1 Fix nice...
...by switching to the NetBSD implementation.

Change-Id: I562b27b237a24ded95804035cc322c7bff12ff59
2012-08-13 16:38:29 -07:00
Raghu Gandham
abd10011a7 MIPS support to sigsuspend and sigwait routines
Change-Id: I870e798ed7eac5a8c74e5784a670f3a4f24331a9
2012-08-09 18:51:19 -07:00
Elliott Hughes
387d4b7de9 Auto-generate a complete NOTICE file.
Remove the hand-collated ones, and switch to a script that pulls the
copyright headers out of every file and collects the unique ones.

Change-Id: Ied3b98b3f56241df97166c410ff81de4e0157c9d
2012-08-09 16:05:31 -07:00
Elliott Hughes
52d6233296 Report errors to the log, not just stderr.
In particular this affects assert(3) and __cxa_pure_virtual, both of
which have managed to confuse people this week by apparently aborting
without reason. (Because stderr goes nowhere, normally.)

Bug: 6852995
Bug: 6840813
Change-Id: I7f5d17d5ddda439e217b7932096702dc013b9142
2012-07-27 17:43:38 -07:00
Chris Dearman
00a66a6fe8 [MIPS] Use an aligned address to provoke SIGSEGV in abort()
Change-Id: I269c9ccc07058773fb0f9d70673673157ab38f6a
2012-07-24 17:42:06 -07:00
Nick Kralevich
a3e230d1fa FORTIFY_SOURCE: Add openat, fix bug
Add fortify_source support for openat(). This change requires that
an argument be supplied when using O_CREAT.

Fix unnecessary call to __open_2. If, at compile time, we know that
"flags" is constant and DOESN'T contain O_CREAT, the call to __open_2
is useless.

Change-Id: Ifcd29c4fb25e25656961d7552d672e161f0cfdbd
2012-07-09 12:30:40 -07:00
Nick Kralevich
8118f62a7d FORTIFY_SOURCE: add open() checks
Add a FORTIFY_SOURCE check which requires that you pass a
"mode" argument when calling open(..., O_CREAT). If a mode isn't
passed, then the file is created with "undefined" permissions.

Change-Id: I4427be4f9ce170c69da01af5b00fb05b03613a28
2012-06-26 15:19:12 -07:00
Elliott Hughes
d0c250271c am 2b89f1e3: Merge "Fix sysconf(_SC_NPROCESSORS_CONF) on ARM."
* commit '2b89f1e37df838e466d382fc602728930bad4c68':
  Fix sysconf(_SC_NPROCESSORS_CONF) on ARM.
2012-06-06 13:48:07 -07:00
Elliott Hughes
a985076bfe Fix sysconf(_SC_NPROCESSORS_CONF) on ARM.
Bug: http://code.google.com/p/enh/issues/detail?id=33
Change-Id: I679b4cd888d362031042284e8edf01c5273a92aa
2012-06-06 12:04:38 -07:00
Ben Cheng
eda7be454d Implement the "abort" stub in assembly for ARM.
So that we can always get the full stack trace regardless of gcc's handling
of the "noreturn" attribute associated with abort().

(Cherry pick of Id264a5167e7cabbf11515fbc48f5469c527e34d4.)

Bug: 6455193

Conflicts:

	libc/Android.mk

Change-Id: I568fc5303fd1d747075ca933355f914122f94dac
2012-05-08 14:47:20 -07:00
Ben Cheng
08b51e2c09 Implement the "abort" stub in assembly for ARM.
So that we can always get the full stack trace regardless of gcc's handling
of the "noreturn" attribute associated with abort().

[cherry-picked from master]

BUG:6455193
Change-Id: I0102355f5bf20e636d3feab9d1424495f38e39e2
2012-05-08 14:39:35 -07:00
Elliott Hughes
8266cf94d3 am ff219e57: am 6435d27f: Merge "bionic: fix NULL parameter failure in getcwd()"
* commit 'ff219e57c0ffe5ac2816f79677ce4f1afa677277':
  bionic: fix NULL parameter failure in getcwd()
2012-04-16 13:15:13 -07:00
Jack Ren
e5bf068147 bionic: fix NULL parameter failure in getcwd()
LTP: getcwd01 failed in LTP

Need to check getcwd parameters, otherwise it will lead to
posix test case to fail.

Change-Id: Ieb673b6dd4ca6481da81c5339dbf7ec0a463f263
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
2012-04-16 23:35:05 +08:00
Iliyan Malchev
1ca0b9d158 Merge "bionic: pass MADV_MERGEABLE on private & anonymous mmaps" 2012-03-21 13:51:42 -07:00
JP Abgrall
b8e1e9685e bionic: pass MADV_MERGEABLE on private & anonymous mmaps
Change-Id: I8bc167bb33dec6417fe772172697ea6ff97da2f6
Signed-off-by: Iliyan Malchev <malchev@google.com>
2012-03-21 13:21:33 -07:00
Nick Kralevich
d1860ad8dd fnmatch.c: Update to version in OpenBSD HEAD
Upgrade fnmatch.c from OpenBSD version 1.13 to 1.16.
This is needed primarily to address CVE-2011-0419.

This is a straight copy from upstream's version at
http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/gen/fnmatch.c and
incorporates the following changes:

Revision 1.16:
New fnmatch(3) implementation which is not recursive.
Written and provided under BSD licence by William A. Rowe Jr.
Originally released in Apache APR-1.4.5.
Merged class matching code from r1.14 and PATH_MAX check from r1.15.
ok miod millert

Revision 1.15:
Put a limit on recursion during matching, and reject input of size greater
or equal PATH_MAX. Based on similar fix made in NetBSD.
ok miod@ millert@

Revision 1.14:
POSIX character class support for fnmatch(3) and glob(3).  OK deraadt@

Version 1.14 introduced charclasses.h, which we copy unmodified
from upstream version 1.1.
http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/gen/charclass.h

Bug: 3435120
Change-Id: I45133468f0c3d439fd10eb087a1c647799f9d25b
2012-03-21 09:53:05 -07:00
Jim Huang
28a7c35fea execvp: bcopy() is deprecated. Use memcpy() instead
The function bcopy() is marked as LEGACY in POSIX.1-2001 and removed in
POSIX.1-2008. memcpy (POSIX.1-2001) is its recommended replacement.

Change-Id: I2cc0cc4673d1368255afd11132ddbfd3f87b530b
2012-01-14 11:22:36 +08:00
Bruce Beare
a37f372973 readdir: fix interface to kernel getdents64 function
Issue:
  The kernel will pad the entry->d_reclen in a getdents64 call to a
  long-word boundary.  For very long records, this could exceed the
  size of a struct dirent. The mismatch in the size was causing error
  paranoid checking code in bionic to fail... thus causing an early
  "end" when reading the dirent structures from the kernel buffer.

Test:
 ls
 mkdir abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu
 ls

Change-Id: I75d1f8e45e1655fdd7bac4a08a481d086f28073a
Author: Bruce Beare <bruce.j.beare@intel.com>
2011-12-19 09:38:48 -08:00
Bruce Beare
7d03c9cbce pathconf: dead loop in bionic function __2_symlinks
Fix dead loops in file ./bionic/libc/unistd/pathconf.c

Change-Id: I7a1e6bcd9879c96bacfd376b88a1f899793295c8
Author: Jin Wei <wei.a.jin@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
2011-12-07 09:47:20 -08:00
JP Abgrall
3884bfe966 libc: popen: work around data corruption
vfork() would not save the registers that the parent would expect
to have restored after execl() completed.
Specially that execl() would call execve() underneath, further messing
up the stack of the parent.
To avoid that, we fork() for now. Later we will revisit and cleanup
vfork()+execve() to actually have vfork() store all the register
that the parent expects to see, and not those left by execve().

In the original code, looking at the registers just before the call to
popen(), and after the call showed that r7 would get clobbered.
This would leave the caller with an invalid pointer, leading to all
kinds of data corruptions.
execve() is simpler that execl() in this case.


Bug: 5336252
Change-Id: I3bf718c0bb4c0439f6f2753f153cdea14175be9c
2011-09-17 15:22:21 -07:00
David Turner
6b577759b2 am f2ebd304: am 57aadbb0: Merge "enable support for large files (> 2G)"
* commit 'f2ebd304c3c0822121e6a4d0f542a048a7fc3b20':
  enable support for large files (> 2G)
2011-07-13 14:53:34 -07:00
David Turner
f2ebd304c3 am 57aadbb0: Merge "enable support for large files (> 2G)"
* commit '57aadbb096a118dd33f9f16c67bd18dbb6b92c4a':
  enable support for large files (> 2G)
2011-07-11 10:46:00 -07:00
Dragos Tatulea
0e1723e684 enable support for large files (> 2G)
bionic has an i386 ifdef guard for the O_LARGEFILE flag. The reason for this
is not traceable in the git history, but it's most likely due to some old
toolchain or emulator problem.

Bug Id: 10035

Change-Id: I742ee6e50220276c2cb268d66f89b5655ef689fc
Signed-off-by: Dragos Tatulea <dragos.tatulea@intel.com>
2011-07-05 15:36:43 +03:00
David Turner
afc92c7023 am c643a4d4: am 2be3f09f: Merge "time: Improve C99 compliance"
* commit 'c643a4d4c71c2caaf016ab402fba99c1c9377567':
  time: Improve C99 compliance
2011-06-24 17:16:56 -07:00
David Turner
c643a4d4c7 am 2be3f09f: Merge "time: Improve C99 compliance"
* commit '2be3f09f2d9b6d35b262f7a6148f51c164bb8cbb':
  time: Improve C99 compliance
2011-06-23 10:01:11 -07:00
Jim Huang
21edf366ea time: Improve C99 compliance
Quote from Linux Programmer's Manual:
  "If t is non-NULL, the return value is also stored in the memory
   pointed to by t."

Change-Id: I8cb66b67e5f34c536ce2f0db76a6dc337c42ea3f
Signed-off-by: Jim Huang <jserv@0xlab.org>
2011-06-22 16:44:45 +08:00
Carl Shapiro
2cc2b2be69 Add some missing includes.
Change-Id: Ieec623c06bc32ec78334f628af25b00c2bccd2e7
2011-03-21 20:01:03 -07:00
Brad Fitzpatrick
38e53adadd am c59b2482: am 5a6f593b: Merge "Use sigemptyset to initialise sigset_t values. sigset_t may not be implemented as an integral type."
* commit 'c59b248241b18492d20e112230a907c14400275b':
  Use sigemptyset to initialise sigset_t values. sigset_t may not be implemented as an integral type.
2011-03-16 11:43:29 -07:00
Chris Dearman
c1519a52ef Use sigemptyset to initialise sigset_t values.
sigset_t may not be implemented as an integral type.

Change-Id: I3f5ec86d6383685979d8d23ef508b6c609569b38
Signed-off-by: Raghu Gandham <raghu@mips.com>
2011-03-14 12:15:22 -07:00
Colin Cross
5c6a8a6f41 am 84f4753d: am 56faf66f: raise: Send signal to current thread
* commit '84f4753d1b5f89ace0cc89021916f6f5b44e6540':
  raise: Send signal to current thread
2011-01-21 12:40:07 -08:00
Colin Cross
56faf66fd7 raise: Send signal to current thread
Change-Id: Ie4318b8ddd01cc2f58f5e07c1d71376953943153
2011-01-21 11:39:15 -08:00
Glenn Kasten
2cc0d38afb Bug 3330205, 3362385 clock(3) SMP safety and epoch
Change-Id: Ida1e4400489c8c19818c6af5640ab89942c8f712
2011-01-19 16:14:51 -08:00
David 'Digit' Turner
95d751feac libc: Add ftruncate64 and improve 64-bit parameter syscall handling.
This patch improves the handling of 64-bit parameters in syscalls on ARM.
The ARM EABI mandates that 64-bit quantities be passed in even/odd register
pairs, which requires special treatment.

This allows us to simplify our implementations of pread() and pwrite()
and remove the C stubs for pread64() and pwrite64().

Also add ftruncate64() to <unistd.h>

Change-Id: I407e2fd223ba0093dd2d0b04c6152fadfc9ce3ef

Bug 3107933
2010-12-16 17:04:41 +01:00
Bruce Beare
ff3129b0fe sigsetmask.c was not processing the "mask" argument.
Change-Id: I79b898ea5b882e8c0564e25466e827a9bedda6e8
Author: yhe19 <yunan.he@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
2010-12-09 15:17:28 -08:00
Yu Shan Emily Lau
abdffc4e23 Revert "sigsetmask.c was not processing the "mask" argument."
This reverts commit 9a9c1619b8.
2010-12-09 11:57:42 -08:00
Jean-Baptiste Queru
5d7995be24 am b11d7c3e: am bcb0a925: Merge "sigsetmask.c was not processing the "mask" argument."
* commit 'b11d7c3eca0e5bc04c14afe82a530429f173706c':
  sigsetmask.c was not processing the "mask" argument.
2010-12-06 16:44:30 -08:00