[openssl-users] Session params output fails via cron

Michael Wojcik Michael.Wojcik at microfocus.com
Fri Jan 4 21:04:02 UTC 2019

> From: openssl-users [mailto:openssl-users-bounces at openssl.org] On Behalf Of Jordan Brown
> Sent: Friday, January 04, 2019 13:16

> If you want to, what you want is something like:
>       int fd;
>       do {
>               fd = open("/dev/null", O_RDWR);
>       } while (fd < 3);
>       close(fd);
> (That's strictly not quite right, since it leaves 0 open writable and 1 and 2 open readable,
> but that's pretty harmless.)

Behavior is unfortunate if open fails, e.g. because the NFILES limit is reached, or because /dev/null is inaccessible (e.g. due to a poorly-configured chroot). You'd be better off with (fd >= 0 && fd < 3).

Since source bytes are cheap, though, and there are at most three opens to be done, I'd just do it explicitly for the three stdio descriptors. That would also make the intention clear. (Yes, the intention of your version is clear to old UNIX hands. It might not be to other people.)

I'm ignoring portability considerations, since I personally don't think this would be a great thing to implement in the apps, so I'm not going to be submitting a PR for it.

Michael Wojcik
Distinguished Engineer, Micro Focus

More information about the openssl-users mailing list