Bug 42080: (follow-up) limit data sent to libmagic to 100 characters
By limiting the data sent to libmagic to 100 characters, we make the test faster and we avoid situations where a large or malicious file causes too many resources to be used. 100 characters is more than enough for the file types we're allowing. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
1c6328b82b
commit
9a39e4799a
|
|
@ -74,7 +74,8 @@ if ( $op eq 'download' ) {
|
|||
my $ftype = $file->{'file_type'};
|
||||
|
||||
my $magic = File::LibMagic->new();
|
||||
my $magic_info = $magic->info_from_string( $file->{'file_content'} );
|
||||
my $test_str = substr( $file->{'file_content'}, 0, 99 );
|
||||
my $magic_info = $magic->info_from_string( \$test_str );
|
||||
my $magic_mime_type = $magic_info->{mime_type};
|
||||
if ( $input->param('view') && ( $magic_mime_type && $allowed_ftypes->{$magic_mime_type} ) ) {
|
||||
print $input->header(
|
||||
|
|
|
|||
Loading…
Reference in New Issue