Subject: | Net::HL7::Message: new(): insufficient parameter check |
The ctor for Net::HL7::Message has an optional string argument. If given it will parse this string as a hl7 message. If the string given is not a hl7 Message, the parser sometimes does not detect this well and continues parsing. As a result the program eventually will terminate within the module because of some broken RE.
Sample:
...
$msg = new Net::HL7::Message('bang');
Fix: Extend the checks / evaluation of the MSH segment. Return undef (as the docs mention) in case of errors.
Please find attached a patch for the Module 0.75 to make the module more robust.
PS: Many thanks for the module
Subject: | patch-lib_Net_HL7_Message.pm |
--- lib/Net/HL7/Message.pm.orig 2009-02-05 09:11:57 UTC
+++ lib/Net/HL7/Message.pm
@@ -130,9 +130,14 @@ sub _init {
my ($hdr, $fldSep, $compSep, $repSep, $esc, $subCompSep, $fldSepCtrl) =
($1, $2, $3, $4, $5, $6, $7);
+ # check for MSH
+ if( not defined $hdr or $hdr ne 'MSH' ) {
+ return undef;
+ }
+
# Check whether field separator is repeated after 4 control characters
- if ($fldSep ne $fldSepCtrl) {
+ if (not defined $fldSep or not defined $fldSepCtrl or $fldSep ne $fldSepCtrl) {
return undef;
}