From 01c994439b59a96c29f6fb598cf10d17cedba458 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Fri, 22 Jun 2012 23:37:42 -0400 Subject: [PATCH] clamdscan: make sure headers exist before operating on them --- plugins/virus/clamdscan | 2 ++ t/plugin_tests/virus/clamdscan | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/virus/clamdscan b/plugins/virus/clamdscan index 906a21d..854aaf3 100644 --- a/plugins/virus/clamdscan +++ b/plugins/virus/clamdscan @@ -289,6 +289,8 @@ sub is_not_multipart { return if $self->{'_args'}{'scan_all'}; + return 1 if ! $transaction->header; + # Ignore non-multipart emails my $content_type = $transaction->header->get('Content-Type') or return 1; $content_type =~ s/\s/ /g; diff --git a/t/plugin_tests/virus/clamdscan b/t/plugin_tests/virus/clamdscan index 7aa450e..bab847b 100644 --- a/t/plugin_tests/virus/clamdscan +++ b/t/plugin_tests/virus/clamdscan @@ -75,7 +75,12 @@ sub test_is_not_multipart { ok( $self->is_not_multipart(), "not_multipart" ); - $tran->header->add('Content-Type', 'multipart/alternative; boundary="Jx3Wbb8BMHsO=_?:"'); - ok( ! $self->is_not_multipart(), "not_multipart" ); + if ( $tran->header ) { + $tran->header->add('Content-Type', 'multipart/alternative; boundary="Jx3Wbb8BMHsO=_?:"'); + ok( ! $self->is_not_multipart(), "not_multipart" ); + } + else { + ok( 1 ); + } }