From: Jason Stephenson Date: Tue, 23 Oct 2012 14:36:48 +0000 (-0400) Subject: LP#1070470: Limit variable fields to 255 characters. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a933d99cc6339d77fe159c8dd70d9deeba5fdc3a;p=working%2FSIPServer.git LP#1070470: Limit variable fields to 255 characters. The SIP2 protocol document specifies that variable fields are to be from 0 to 255 characters in length, not counting the field identifier or the delimiter. This branch adds some defensive coding to Sip::add_field to truncate any field values that are longer than 255 characters to 255 characters before adding them to the response. Signed-off-by: Jason Stephenson Signed-off-by: Galen Charlton --- diff --git a/Sip.pm b/Sip.pm index 9dea1c1..a687cd7 100644 --- a/Sip.pm +++ b/Sip.pm @@ -90,6 +90,13 @@ sub add_field { substr($value, $i, 1) = $ent; } + # SIP2 Protocol document specifies that variable fields are from 0 + # to 255 characters in length. We'll do a check of the field + # length and truncate if necessary. + if (length($value) > 255) { + $value = substr($value, 0, 255); + } + return $field_id . $value . $field_delimiter; } #