public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/release/2.35/master] elf: Fix wrong fscanf usage on tst-pldd
@ 2022-11-25 14:31 Arjun Shankar
  0 siblings, 0 replies; 2+ messages in thread
From: Arjun Shankar @ 2022-11-25 14:31 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cad7947db7f464506773a10aa88655ce2d9cf9a0

commit cad7947db7f464506773a10aa88655ce2d9cf9a0
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 5 12:58:40 2022 -0300

    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.
    
    (cherry picked from commit c353689e49e72f3aafa1a9e68d4f7a4f33a79cbe)

Diff:
---
 elf/tst-pldd.c | 9 +++++----
 1 file 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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [glibc/release/2.35/master] elf: Fix wrong fscanf usage on tst-pldd
@ 2022-11-25 14:31 Arjun Shankar
  0 siblings, 0 replies; 2+ messages in thread
From: Arjun Shankar @ 2022-11-25 14:31 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2636fbb7efa8ba6ee101fa64f2295e5f118b8d96

commit 2636fbb7efa8ba6ee101fa64f2295e5f118b8d96
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 11:16:49 2022 -0300

    elf: Fix wrong fscanf usage on tst-pldd
    
    To take in consideration the extra '\0'.
    
    Checked on x86_64-linux-gnu.
    
    (cherry picked from commit b2cd93fce666fdc8c9a5c64af2741a8a6940ac99)

Diff:
---
 elf/tst-pldd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/elf/tst-pldd.c b/elf/tst-pldd.c
index f31f9956fa..8916ce5a2e 100644
--- a/elf/tst-pldd.c
+++ b/elf/tst-pldd.c
@@ -113,7 +113,8 @@ do_test (void)
     TEST_VERIFY (out != NULL);
 
     /* First line is in the form of <pid>: <full path of executable>  */
-    TEST_COMPARE (fscanf (out, "%u: " STRINPUT (512), &pid, buffer), 2);
+    TEST_COMPARE (fscanf (out, "%u: " STRINPUT (sizeof (buffer) - 1), &pid,
+			  buffer), 2);
 
     TEST_COMPARE (pid, *target_pid_ptr);
     TEST_COMPARE (strcmp (basename (buffer), "tst-pldd"), 0);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-25 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 14:31 [glibc/release/2.35/master] elf: Fix wrong fscanf usage on tst-pldd Arjun Shankar
  -- strict thread matches above, loose matches on Subject: below --
2022-11-25 14:31 Arjun Shankar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).