News for hackers. Stuff that matters.
Re:OpenBSD now enforcing no invalid NUL characters in shell ... by amiga386 on Tuesday September 24, 2024 @10:48AM (#41637077)
Here's the actual diff:

https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/bin/ksh/shf.c....

And it looks like that covers all parsed parts of the shell script or history file, including heredocs. I get the feeling it's going to break all shar archives with binary files (not that they're particularly common). It will stop NULs being in the script itself, but it won't stop them coming from other sources, e.g.

    $ var=$(printf '\0hello')
    -bash: warning: command substitution: ignored null byte in input
    $ echo $var
    hello
It remains to be seen if this will be adopted by anyone else, or if it'll be another reason to use OpenBSD only as a restricted environment and not as a general computing platform.

> "If there is ONE THING the Unix world needs, it is for bash/ksh/sh to stop diverging further"

> OpenBSD ksh: diverges further

Re:OpenBSD now enforcing no invalid NUL characters in shell ... by matrix2003 on Tuesday September 24, 2024 @11:00AM (#41637242)
Eh - I actually like developing on OpenBSD first, because of restrictions like this. If it runs on OpenBSD, you are likely to have fewer bugs around things like malloc.

OpenBSD is also really good about upstreaming bug fixes, which is a good thing. Firefox used to be a dumpster fire of core dumps on OpenBSD, and many issues were uncovered and fixed that way.

Re:OpenBSD now enforcing no invalid NUL characters in shell ... by chasil on Tuesday September 24, 2024 @01:03PM (#41638588)
The only thing that is required to happen is that they all obey the rules of the POSIX shell (when called as /bin/sh).

Otherwise, anything goes.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...

All the userland utilities must have the behavior (and problems) specified here:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/

Re:OpenBSD now enforcing no invalid NUL characters in shell ... by bell-cot on Tuesday September 24, 2024 @02:22PM (#41639473)
> Here's the actual diff:

Only 8 short, simple lines of c code. Beautiful.

Re:OpenBSD now enforcing no invalid NUL characters in shell ... by raverbashing on Wednesday September 25, 2024 @12:53AM (#41643811)
> I get the feeling it's going to break all shar archives with binary files (not that they're particularly common)

Base64 encode them.

This is not diverging further, this is bringing sanity to the table

Re:OpenBSD now enforcing no invalid NUL characters in shell ... by jolmg on Wednesday September 25, 2024 @04:21PM (#41651448)
> I get the feeling it's going to break all shar archives with binary files

shar encodes binary files. Here's what it does with a file that has contents: "foo\0bar\n":

    sed 's/^X//' << 'SHAR_EOF' | uudecode &&
  begin 600 foo.txt
  (9F]O`&)A<@K.
  `
  end
  SHAR_EOF

Interestingly, passing that heredoc to uudecode in the shell, it produces no output. However, if I pass the whole shar output to unshar, it does produce the file with the correct content.