|
|
c641a2 |
commit c353689e49e72f3aafa1a9e68d4f7a4f33a79cbe
|
|
|
c641a2 |
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
c641a2 |
Date: Tue Jul 5 12:58:40 2022 -0300
|
|
|
c641a2 |
|
|
|
c641a2 |
elf: Fix wrong fscanf usage on tst-pldd
|
|
|
c641a2 |
|
|
|
c641a2 |
The fix done b2cd93fce666fdc8c9a5c64af2741a8a6940ac99 does not really
|
|
|
c641a2 |
work since macro strification does not expand the sizeof nor the
|
|
|
c641a2 |
arithmetic operation.
|
|
|
c641a2 |
|
|
|
c641a2 |
Checked on x86_64-linux-gnu.
|
|
|
c641a2 |
|
|
|
c641a2 |
diff --git a/elf/tst-pldd.c b/elf/tst-pldd.c
|
|
|
c641a2 |
index ab89798e250fdccc..52c0a75be5a808d1 100644
|
|
|
c641a2 |
--- a/elf/tst-pldd.c
|
|
|
c641a2 |
+++ b/elf/tst-pldd.c
|
|
|
c641a2 |
@@ -108,15 +108,16 @@ do_test (void)
|
|
|
c641a2 |
loader and libc. */
|
|
|
c641a2 |
{
|
|
|
c641a2 |
pid_t pid;
|
|
|
c641a2 |
- char buffer[512];
|
|
|
c641a2 |
-#define STRINPUT(size) "%" # size "s"
|
|
|
c641a2 |
+#define BUFFERLEN 511
|
|
|
c641a2 |
+ char buffer[BUFFERLEN + 1];
|
|
|
c641a2 |
+#define STRINPUT(size) XSTRINPUT(size)
|
|
|
c641a2 |
+#define XSTRINPUT(size) "%" # size "s"
|
|
|
c641a2 |
|
|
|
c641a2 |
FILE *out = fmemopen (pldd.out.buffer, pldd.out.length, "r");
|
|
|
c641a2 |
TEST_VERIFY (out != NULL);
|
|
|
c641a2 |
|
|
|
c641a2 |
/* First line is in the form of <pid>: <full path of executable> */
|
|
|
c641a2 |
- TEST_COMPARE (fscanf (out, "%u: " STRINPUT (sizeof (buffer) - 1), &pid,
|
|
|
c641a2 |
- buffer), 2);
|
|
|
c641a2 |
+ TEST_COMPARE (fscanf (out, "%u: " STRINPUT (BUFFERLEN), &pid, buffer), 2);
|
|
|
c641a2 |
|
|
|
c641a2 |
TEST_COMPARE (pid, *target_pid_ptr);
|
|
|
c641a2 |
TEST_COMPARE (strcmp (basename (buffer), "tst-pldd"), 0);
|