From: "(GalaxyMaster)" <galaxy@openwall.com.au>
To: musl@lists.openwall.com
Cc: 2010267516@qq.com, Kaihang Zhang <kaihang.zhang@smartx.com>
Subject: Re: [musl] [PATCH] fix: Assign default value to mntent when linebuf is too small
Date: Tue, 12 Oct 2021 03:24:07 +0000 [thread overview]
Message-ID: <0100017c7287622f-cceed952-52dc-4c02-b1af-b3943a41203c-000000@email.amazonses.com> (raw)
In-Reply-To: <20211012023643.44509-1-kaihang.zhang@smartx.com>
Kaihang,
On Mon, Oct 11, 2021 at 10:36:43PM -0400, Kaihang Zhang wrote:
> Function getmntent_r in source misc/mntent.c will do what glibc users
> expect. The rest of the line will be discarded when can not be read
> into linebuf, and the fields of struct mntent will be assigned to empty
> string or zero when can not be found in linebuf, instead of setting
> errno to ERANGE and exiting.
Although this patch is on a similar topic as mine (changing the behaviour of
get*ent() funnctions), I think the change you are describing is considerable.
I would expect a function such as getmntent_r() which takes a user provided
buffer to fail and set ERANGE if the provided buffer is not enough to hold
the line. This gives the developer an opportunity to recover, e.g. to
re-allocate a bigger buffer and try again.
In your proposal, I see two issues:
1. There is no feedback to the developer, so they have no idea whether the
information they've got from the function was truncated or not (and what
good does a truncated mnt line bring?);
2. There is no opportunity for the developer to realise a mistake they made
by supplying too small buffer, hence there is no chance of recovering
from it.
It is just my opinion and I would love to see other comments, since I have
not stumbled upon your use case yet and am not authoritative on this topic.
--
(GM)
next prev parent reply other threads:[~2021-10-12 11:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 2:36 Kaihang Zhang
2021-10-12 3:24 ` (GalaxyMaster) [this message]
2021-10-12 12:59 ` Rich Felker
2021-10-15 7:19 ` Kaihang Zhang
2021-10-27 14:34 ` [musl] Changes to getmntent Alyssa Ross
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=0100017c7287622f-cceed952-52dc-4c02-b1af-b3943a41203c-000000@email.amazonses.com \
--to=galaxy@openwall.com.au \
--cc=2010267516@qq.com \
--cc=kaihang.zhang@smartx.com \
--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).