From: Alyssa Ross <hi@alyssa.is>
To: musl@lists.openwall.com
Cc: Alyssa Ross <hi@alyssa.is>
Subject: [musl] [PATCH libc-test 2/3] functional: add mntent test for single-field line
Date: Sat, 21 Aug 2021 08:54:19 +0000 [thread overview]
Message-ID: <20210821085420.474615-3-hi@alyssa.is> (raw)
In-Reply-To: <20210821085420.474615-1-hi@alyssa.is>
Glibc only requires a single field to be present in an fstab line to
parse it, and will initialize all other string fields to the empty
string. This test checks for that behaviour.
---
I'm providing this test as a seperate patch to make it easy to pass on
this test while still accepting the rest, because I'm not sure whether
it's a good thing or not for Musl to allow fstab lines like this, even
though Glibc does.
src/functional/mntent.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/functional/mntent.c b/src/functional/mntent.c
index 59d816a..caa7d33 100644
--- a/src/functional/mntent.c
+++ b/src/functional/mntent.c
@@ -31,6 +31,18 @@ void test_getmntent_empty(void)
ASSERT(endmntent(f) == 1);
}
+void test_getmntent_short(void)
+{
+ char fstab[] = "1\n";
+ FILE *f = fmemopen((void *)fstab, sizeof fstab - 1, "r");
+ if (!f) ERR("fmemopen");
+ struct mntent *m = getmntent(f);
+ ASSERT(m);
+ ASSERT(!strcmp(m->mnt_fsname, "1"));
+ ASSERT(!*m->mnt_dir);
+ ASSERT(endmntent(f) == 1);
+}
+
void test_getmntent(void)
{
// Checks that the fifth and sixth fields default to 0.
@@ -71,6 +83,7 @@ void test_getmntent_r(void)
int main(void)
{
test_getmntent_empty();
+ test_getmntent_short();
test_getmntent();
test_getmntent_r();
}
--
2.32.0
next prev parent reply other threads:[~2021-08-21 18:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-21 8:54 [musl] [PATCH 0/3] mntent: fix parsing lines with optional fields Alyssa Ross
2021-08-21 8:54 ` [musl] [PATCH libc-test 1/3] functional: add mntent test Alyssa Ross
2021-08-21 8:54 ` Alyssa Ross [this message]
2021-08-21 8:54 ` [musl] [PATCH musl 3/3] mntent: fix parsing lines with optional fields Alyssa Ross
2021-08-27 15:27 ` Érico Nogueira
2021-08-27 16:49 ` Rich Felker
2021-08-27 16:59 ` Rich Felker
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=20210821085420.474615-3-hi@alyssa.is \
--to=hi@alyssa.is \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).