diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-09-09 20:15:17 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-09-09 20:15:17 +0000 |
commit | 2036b767dd60813df266647ab1e23159f5043706 (patch) | |
tree | a7ad57b706291a07bec430d639656a1f80e4c7a2 | |
parent | 4af35571fb0335347c263f2446c1f2fa6de28f49 (diff) | |
download | glibc-2036b767dd60813df266647ab1e23159f5043706.zip glibc-2036b767dd60813df266647ab1e23159f5043706.tar.gz glibc-2036b767dd60813df266647ab1e23159f5043706.tar.bz2 |
(main): Check memccpy.
-rw-r--r-- | string/stratcliff.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/string/stratcliff.c b/string/stratcliff.c index 9b0e421..6377c6e 100644 --- a/string/stratcliff.c +++ b/string/stratcliff.c @@ -1,5 +1,5 @@ /* Test for string function add boundaries of usable memory. - Copyright (C) 1996,1997,1999,2000,2001,2002 Free Software Foundation, Inc. + Copyright (C) 1996,1997,1999-2002,2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -306,6 +306,43 @@ main (int argc, char *argv[]) outer, inner); result = 1; } + + /* memccpy test */ + memset (adr, '\0', size); + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + for (inner = 0; inner < size - outer; ++inner) + if (memccpy (dest, &adr[outer], '\1', inner) != NULL) + { + printf ("memccpy flunked full copy for outer = %d, inner = %d\n", + outer, inner); + result = 1; + } + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + for (middle = 0; middle < size - outer; ++middle) + { + memset (dest, '\2', middle + 1); + for (inner = 0; inner < middle; ++inner) + { + adr[outer + inner] = '\1'; + + if (memccpy (dest, &adr[outer], '\1', middle + 128) + != dest + inner + 1) + { + printf ("\ +memccpy flunked partial copy for outer = %d, middle = %d, inner = %d\n", + outer, middle, inner); + result = 1; + } + else if (dest[inner + 1] != '\2') + { + printf ("\ +memccpy copied too much for outer = %d, middle = %d, inner = %d\n", + outer, middle, inner); + result = 1; + } + adr[outer + inner] = '\0'; + } + } } return result; |