public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Sandeep Patil <sspatil@google.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2] android: madvise08: fix for android devices.
Date: Tue,  5 Sep 2017 15:33:02 -0700	[thread overview]
Message-ID: <20170905223302.85238-1-sspatil@google.com> (raw)

The test uses '%m' conversion specifier for vfscanf() that is not
supported in bionic. Use '%s' instead with a buffer that is substatially
larger than the current maximum coredump file name length of 128 bytes.

Signed-off-by: Sandeep Patil <sspatil@google.com>
---
v1->v2
---
- Fix the possibility of incorrectly replacing the coredump filename
  pattern by an empty string in the test failure path.

 testcases/kernel/syscalls/madvise/madvise08.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/syscalls/madvise/madvise08.c b/testcases/kernel/syscalls/madvise/madvise08.c
index 296c2bff3..a6fd9671c 100644
--- a/testcases/kernel/syscalls/madvise/madvise08.c
+++ b/testcases/kernel/syscalls/madvise/madvise08.c
@@ -49,10 +49,12 @@
 #define CORE_FILTER "/proc/self/coredump_filter"
 #define YCOUNT 0x500L
 #define FMEMSIZE (YCOUNT + 0x2L)
+#define CORENAME_MAX_SIZE 512
 
 static int dfd;
 static void *fmem;
-static char *cpattern;
+static char cpattern[CORENAME_MAX_SIZE];
+static int restore_cpattern;
 
 static void setup(void)
 {
@@ -80,7 +82,8 @@ static void setup(void)
 	if (!(0x1 & filter))
 		tst_brk(TCONF, "Anonymous private memory is not dumpable.");
 
-	SAFE_FILE_SCANF(CORE_PATTERN, "%m[^\n]", &cpattern);
+	SAFE_FILE_SCANF(CORE_PATTERN, "%s[^\n]", cpattern);
+	restore_cpattern = 1;
 	tst_res(TINFO, "System core pattern is '%s'", cpattern);
 
 	SAFE_GETCWD(cwd, sizeof(cwd));
@@ -108,11 +111,9 @@ static void setup(void)
 
 static void cleanup(void)
 {
-	if (cpattern)
+	if (restore_cpattern)
 		SAFE_FILE_PRINTF(CORE_PATTERN, "%s", cpattern);
 
-	free(cpattern);
-
 	if (fmem)
 		SAFE_MUNMAP(fmem, FMEMSIZE);
 
-- 
2.14.1.581.gf28d330327-goog


             reply	other threads:[~2017-09-05 22:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-05 22:33 Sandeep Patil [this message]
2017-09-08  9:22 ` [LTP] [PATCH v2] android: madvise08: fix for android devices Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170905223302.85238-1-sspatil@google.com \
    --to=sspatil@google.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox