aboutsummaryrefslogtreecommitdiffstats
path: root/libc/string/memmove.c
Commit message (Collapse)AuthorAgeFilesLines
* Move non-upstream code into the libc/bionic directory.Elliott Hughes2012-10-011-46/+0
| | | | | | | 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
* FORTIFY_SOURCE: enhanced memcpy protections.Nick Kralevich2012-07-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two changes: 1) Detect memory read overruns. For example: int main() { char buf[10]; memcpy(buf, "abcde", sizeof(buf)); sprintf("%s\n", buf); } because "abcde" is only 6 bytes, copying 10 bytes from it is a bug. This particular bug will be detected at compile time. Other similar bugs may be detected at runtime. 2) Detect overlapping buffers on memcpy() It is a bug to call memcpy() on buffers which overlap. For example, the following code is buggy: char buf3[0x800]; char *first_half = &buf3[0x400]; char *second_half = &buf3[1]; memset(buf3, 0, sizeof(buf3)); memcpy(first_half, second_half, 0x400); printf("1: %s\n", buf3); We now detect this at compile and run time. Change-Id: I092bd89f11f18e08e8a9dda0ca903aaea8e06d91
* memmove: Don't call memcpy if regions overlapNick Kralevich2012-07-111-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | memmove() unconditionally calls memcpy() if "dst" < "src". For example, in the code below, memmove() would end up calling memcpy(), even though the regions of memory overlap. int main() { char buf3[0x800]; char *dst = &buf3[1]; char *src = &buf3[0x400]; memset(buf3, 0, sizeof(buf3)); memmove(dst, src, 0x400); printf("1: %s\n", buf3); return 0; } Calling memcpy() on overlaping regions only works if you assume that memcpy() copies from start to finish. On some architectures, it's more efficient to call memcpy() from finish to start. This is also triggering a failure in some of my code. More reading: * http://lwn.net/Articles/414467/ * https://bugzilla.redhat.com/show_bug.cgi?id=638477#c31 (comment 31) Change-Id: I65a51ae3a52dd4af335fe5c278056b8c2cbd8948
* Use more optimized version of memmoveJohannes Carlsson2011-02-031-34/+3
| | | | | | | | | On ARM there is currently no assembler optimized memmove in libc. There is however a more optimized bcopy which copies long instead of bytes where possible. This almost doubles the performance in best case. Change-Id: I1f1cd27529443358047c385730deaf938ce4e642
* libc: optimize memmove() with memcpy() if possible.David 'Digit' Turner2010-10-071-1/+4
| | | | Change-Id: I90e578fdc82e427caee8fa4157ce3f8c6c99926d
* Revert "libc: memmove(): non-overlapping block optim."Marco Nelissen2010-09-281-5/+1
| | | | | | | | This reverts commit 80fba9a2fe4eacaabee99cf0bbead872c2792231, which caused the system to not boot anymore, aborting with: "java.lang.RuntimeException: Missing static main on com.android.server.SystemServer". Change-Id: I745e0a23c728cccf5f95a3c7642d544478a4e57e
* libc: memmove(): non-overlapping block optim.David 'Digit' Turner2010-09-271-1/+5
| | | | Change-Id: I5652f4f97ca59d95176443fc27c737ef76258183
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-0/+72
|
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-72/+0
|
* Initial Contributionandroid-1.0The Android Open Source Project2008-10-211-0/+72