about summary refs log tree commit diff
path: root/elf/tst-pldd.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-07-05 12:58:40 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-07-15 10:07:55 -0300
commitc353689e49e72f3aafa1a9e68d4f7a4f33a79cbe (patch)
tree85a39e3f225d1e30c12726d09030497329a8780b /elf/tst-pldd.c
parentd0fa09a7701956036ff36f8ca188e9fff81553d8 (diff)
downloadglibc-c353689e49e72f3aafa1a9e68d4f7a4f33a79cbe.tar.gz
glibc-c353689e49e72f3aafa1a9e68d4f7a4f33a79cbe.tar.xz
glibc-c353689e49e72f3aafa1a9e68d4f7a4f33a79cbe.zip
elf: Fix wrong fscanf usage on tst-pldd
The fix done b2cd93fce666fdc8c9a5c64af2741a8a6940ac99 does not really
work since macro strification does not expand the sizeof nor the
arithmetic operation.

Checked on x86_64-linux-gnu.
Diffstat (limited to 'elf/tst-pldd.c')
-rw-r--r--elf/tst-pldd.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/elf/tst-pldd.c b/elf/tst-pldd.c
index 0616545b1d..9f633d41a2 100644
--- a/elf/tst-pldd.c
+++ b/elf/tst-pldd.c
@@ -108,15 +108,16 @@ do_test (void)
      loader and libc.  */
   {
     pid_t pid;
-    char buffer[512];
-#define STRINPUT(size) "%" # size "s"
+#define BUFFERLEN 511
+    char buffer[BUFFERLEN + 1];
+#define STRINPUT(size)  XSTRINPUT(size)
+#define XSTRINPUT(size) "%" # size "s"
 
     FILE *out = fmemopen (pldd.out.buffer, pldd.out.length, "r");
     TEST_VERIFY (out != NULL);
 
     /* First line is in the form of <pid>: <full path of executable>  */
-    TEST_COMPARE (fscanf (out, "%u: " STRINPUT (sizeof (buffer) - 1), &pid,
-			  buffer), 2);
+    TEST_COMPARE (fscanf (out, "%u: " STRINPUT (BUFFERLEN), &pid, buffer), 2);
 
     TEST_COMPARE (pid, *target_pid_ptr);
     TEST_COMPARE (strcmp (basename (buffer), "tst-pldd"), 0);