From: Jeff Godin Date: Mon, 11 Jul 2016 19:00:51 +0000 (-0400) Subject: LP#1628995 Fix output message length calculation X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a2400e60e8aab5ae15155f879ddc4dafbcaa5191;p=working%2FSIPServer.git LP#1628995 Fix output message length calculation In cases where an output message has a different number of logical characters than bytes, SIPServer can incorrectly calculate the length of the message, resulting in an incomplete message being sent. Since the message lacks the SIP2 Message Terminator character (CR, 0x0d), client behavior is unpredictable. Some clients will hang. A "use bytes;" pragma forces the length() call to disable character semantics, so that the correct number of bytes is passed to POSIX::write(). Future changes may result in output messages never reaching this point in a state where Perl will apply character semantics, but for now this handles the problem without hanging clients. Signed-off-by: Jeff Godin --- diff --git a/Sip.pm b/Sip.pm index d9f14c4..8fd4717 100644 --- a/Sip.pm +++ b/Sip.pm @@ -245,6 +245,7 @@ sub write_msg { if ($file) { print $file $outmsg; } else { + use bytes; my $rv = POSIX::write(fileno(STDOUT), $outmsg, length($outmsg)); syslog("LOG_ERR", "Error writing to STDOUT $!") unless $rv; }