From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 9D5993857BB2; Fri, 15 Jul 2022 13:16:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D5993857BB2 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] elf: Fix wrong fscanf usage on tst-pldd X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/master X-Git-Oldrev: d0fa09a7701956036ff36f8ca188e9fff81553d8 X-Git-Newrev: c353689e49e72f3aafa1a9e68d4f7a4f33a79cbe Message-Id: <20220715131604.9D5993857BB2@sourceware.org> Date: Fri, 15 Jul 2022 13:16:04 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2022 13:16:04 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c353689e49e72f3aafa1a9e68d4f7a4f33a79cbe commit c353689e49e72f3aafa1a9e68d4f7a4f33a79cbe Author: Adhemerval Zanella 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. 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 : */ - 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);