Subject: | Code for removal of stale locks causes exception in taint mode |
Insecure dependency in truncate while running with -T switch at
/usr/lib/perl5/vendor_perl/5.8.4/File/NFSLock.pm line 215, <_FH>
The taint violation stems from the use of the value returned by
length($content) as the second argument to the truncate() function.
$content is assigned from a readline() operation against a filehandle
opened on the lock file. When taint mode is enabled the value returned
by length($content) is tainted. The attached patch assigns the value
returned by length($content) as a key in an anonymous hash in order to
untaint the value.
Subject: | File-NFSLock.patch |
--- /usr/lib/perl5/vendor_perl/5.8.4/File/NFSLock.pm.orig 2009-01-03 16:46:23.000000000 -0800
+++ /usr/lib/perl5/vendor_perl/5.8.4/File/NFSLock.pm 2009-01-03 16:48:45.000000000 -0800
@@ -209,10 +209,11 @@
}
### Save any valid locks or wipe file.
- if( length($content) ){
+ my ($len) = keys %{+{length($content)}}; # untaint length() return value
+ if( $len ){
seek _FH, 0, 0;
print _FH $content;
- truncate _FH, length($content);
+ truncate _FH, length($len);
close _FH;
}else{
close _FH;