This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
POSIX.xs: Never pass NULL to ctermid()
authorKarl Williamson <khw@cpan.org>
Tue, 17 Mar 2020 17:39:02 +0000 (11:39 -0600)
committerKarl Williamson <khw@cpan.org>
Wed, 18 Mar 2020 23:27:40 +0000 (17:27 -0600)
commit7772648bef28ffe36213fdd4346343773d5344e9
tree8284b351d8d0b392398513df54c3a1537932113c
parent0425a59a8996fca991bfbfdd8e5d1e2707a4b4bf
POSIX.xs: Never pass NULL to ctermid()

Doing so can cause races.

It is interesting that POSIX:ctermid() takes a parameter, but the
pod doesn't indicate that it does.  Prior to this commit the parameter
was ignored if and only if the platform contains a ctermid_r()
function, and hence on such platforms there was no possibility of a race
here.  The man pages I've seen for ctermid_r() indicate that it differs
from regular ctermid() only in that it will fail if the input is NULL,
and hence a race could occur if it didn't immediately fail.

The situation prior to this commit wa that if you followed the pod on a
non-ctermid_r() platform, and called this without a parameter, it would
call ctermid with NULL, creating a potential race.  This commit changes
so that a race is never possible.
ext/POSIX/POSIX.xs
ext/POSIX/lib/POSIX.pm