Fix a memory corruption (NativeCodeTest testPipeReadV)

1. Use after initialize.
    void *bufs[BUFS] is located in stack and does not initilized.
    But, testcase is using the variable before memory allocation.
    So, readv could write to unexpected memory address.

2. Remove useless code.
    iovs[OVERFLOW_BUF - 1] will be initialized after assign.
    So, it is a useless code.

Signed-off-by: Hyangseok Chae <neo.chae@lge.com>

(cherry-picked from 494051e36b243b29bcb1bd7440b07811e01fb2e1)

Change-Id: I95dd691fd60d3b841641f44e3470edd858439c9e
diff --git a/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp b/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
index 12c3517..25dcc9b 100644
--- a/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
+++ b/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
@@ -303,18 +303,14 @@
      * set up to overflow iov[OVERFLOW_BUF] on non-atomic redo in kernel
      * function pipe_iov_copy_to_user
      */
-    iovs[OVERFLOW_BUF - 1].iov_len = IOV_LEN*10;
-    iovs[OVERFLOW_BUF].iov_base = bufs[OVERFLOW_BUF];
-    iovs[OVERFLOW_BUF].iov_len = IOV_LEN;
-
-    overflow_addr = mmap((void *) FIXED_ADDR, PAGE_SIZE, PROT_READ | PROT_WRITE,
-            MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-
-    bufs[OVERFLOW_BUF] = overflow_addr;
+    bufs[OVERFLOW_BUF] = mmap((void*)(FIXED_ADDR), PAGE_SIZE, PROT_READ | PROT_WRITE,
+            MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
     if (bufs[OVERFLOW_BUF] == MAP_FAILED) {
         ALOGE("mmap fixed addr failed:%s", strerror(errno));
         goto __close_pipe;
     }
+    iovs[OVERFLOW_BUF].iov_base = bufs[OVERFLOW_BUF];
+    iovs[OVERFLOW_BUF].iov_len = IOV_LEN;
 
     for (i = 0; i < BUFS; i++) {
         if (i == OVERFLOW_BUF) {