tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: sh(1) read: add LINE_MAX safeguard and "-n" option
Date: Wed, 25 Sep 2024 21:01:12 +0700
From: Robert Elz <kre%munnari.OZ.AU@localhost>
Message-ID: <24247.1727272872%jacaranda.noi.kre.to@localhost>
This isn't avoiding adding a -n that works, but a possible simpler change
that might help, is much easier to install properly, should break nothing,
and I think will probably avoid the problem that is being observed.
That is, currently the read builtin simply ignores \0 bytes in the input,
except if \0 is the delimiter character. We could change that, and make
\0 an error - POSIX specifies that the input shall not contain \0 chars
unless -d has been used to make \0 the delimiter character.
If that change got made, I suspect that the read would terminate quite
quickly on non-text files, and text files will end at the first \n.
Would that be a useful first step at least?
If I do that, I'd probably add an option to retain the current behaviour,
just in case there's something (inappropriately) relying upon it.
kre
Home |
Main Index |
Thread Index |
Old Index