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 20:03:56 +0200
    From:        tlaronde%kergis.com@localhost
    Message-ID:  <ZvRQjAg2qzt-6wQG%kergis.com@localhost>

  | But a nul byte given as an escaped sequence does not generate an error
  | and is discarded (present implementation OK, since choice up to the
  | implementation) conforming to (issue 8, taken from 2.2.4
  | Dollar-Single-Quotes, and applying consistency):

$'' has nothing to do with it, that is describing chars that will become
part of the script, not input to a utility, the relevant text is in read ...

   If the -d delim option is not specified, or if it is specified and
   delim is not the null string, the standard input shall contain zero
   or more bytes (which need not form valid characters) and shall
   not contain any null bytes.

When we have invalid input we can treat it as an error, or we can
do something different.   Currently we just ignore them.  They can't
be included.

But if (from your earlier message) stopping at \0 isn't going to help,
then there's no point changing things.   I had assumed that the files
being checked were generally either #!/whatever files, or binaries.
If there are javascipt, html, and all kinds of other stuff included,
then the \0 check might indeed be not all that useful - but as I said,
that wasn't intended as an alternative to -n, just as something that
could reasonably be done which would allow "read var < file" to work
better than it does now, without needing to be modified.

kre



Home | Main Index | Thread Index | Old Index