Skip Menu |

This queue is for tickets about the Net-HL7 CPAN distribution.

Report information
The Basics
Id: 122191
Status: resolved
Priority: 0/
Queue: Net-HL7

People
Owner: ddokter [...] cpan.org
Requestors: alexander.haderer [...] loescap.de
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.76
Fixed in: 0.82



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; }
Thanks for the patch, I have included the fix in the newest release (0.82). D. On Fri 23 Jun 2017 13:33:37, AFRIKA wrote: Show quoted text
> 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