From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 2/2] syscalls: newuname01: Fix fail on empty domainname
Date: Thu, 7 May 2026 09:50:06 +0200 [thread overview]
Message-ID: <20260507075006.8690-3-chrubis@suse.cz> (raw)
In-Reply-To: <20260507075006.8690-1-chrubis@suse.cz>
The domainname can be empty hence we cannot use scanf() string for
format for reading the file. Use the newly added SAFE_FILE_READ_STR()
to read the strings from procfs instead.
Fixes: https://github.com/linux-test-project/ltp/issues/1304
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
testcases/kernel/syscalls/newuname/newuname01.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/newuname/newuname01.c b/testcases/kernel/syscalls/newuname/newuname01.c
index 37058023a..995ea978e 100644
--- a/testcases/kernel/syscalls/newuname/newuname01.c
+++ b/testcases/kernel/syscalls/newuname/newuname01.c
@@ -31,16 +31,16 @@ static void run(void)
TST_EXP_EQ_STR(name->sysname, "Linux");
- SAFE_FILE_SCANF("/proc/sys/kernel/hostname", "%1023[^\n]", proc_val);
+ SAFE_FILE_READ_STR("/proc/sys/kernel/hostname", proc_val, sizeof(proc_val));
TST_EXP_EQ_STR(name->nodename, proc_val);
- SAFE_FILE_SCANF("/proc/sys/kernel/osrelease", "%1023[^\n]", proc_val);
+ SAFE_FILE_READ_STR("/proc/sys/kernel/osrelease", proc_val, sizeof(proc_val));
TST_EXP_EQ_STR(name->release, proc_val);
- SAFE_FILE_SCANF("/proc/sys/kernel/version", "%1023[^\n]", proc_val);
+ SAFE_FILE_READ_STR("/proc/sys/kernel/version", proc_val, sizeof(proc_val));
TST_EXP_EQ_STR(name->version, proc_val);
- SAFE_FILE_SCANF("/proc/sys/kernel/domainname", "%1023[^\n]", proc_val);
+ SAFE_FILE_READ_STR("/proc/sys/kernel/domainname", proc_val, sizeof(proc_val));
TST_EXP_EQ_STR(name->domainname, proc_val);
}
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-05-07 7:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 7:50 [LTP] [PATCH v2 0/2] Fix proc parsing in newuname01 Cyril Hrubis
2026-05-07 7:50 ` [LTP] [PATCH v2 1/2] lib: safe_file_ops: Add SAFE_FILE_READ_STR() Cyril Hrubis
2026-05-07 8:26 ` [LTP] " linuxtestproject.agent
2026-05-07 8:29 ` Andrea Cervesato via ltp
2026-05-07 8:29 ` [LTP] [PATCH v2 1/2] " Andrea Cervesato via ltp
2026-05-07 7:50 ` Cyril Hrubis [this message]
2026-05-07 8:29 ` [LTP] [PATCH v2 2/2] syscalls: newuname01: Fix fail on empty domainname Andrea Cervesato via ltp
2026-05-07 8:34 ` [LTP] [PATCH v2 0/2] Fix proc parsing in newuname01 Andrea Cervesato via ltp
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=20260507075006.8690-3-chrubis@suse.cz \
--to=chrubis@suse.cz \
--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