Skip to content

Commit

Permalink
Gracefully detect cut-off netstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
supernovus committed Sep 26, 2011
1 parent 547e6ec commit 72c64e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,2 +1,3 @@
Makefile
blib
blib
*.swp
6 changes: 5 additions & 1 deletion lib/SCGI.pm
Expand Up @@ -26,14 +26,18 @@ class SCGI::Request {
}

method parse {
$.request = $.connection.get();#recv();
$.request = $.connection.get();#recv(); ## FIXME!
my $rlen = $.request.chars;
if $.debug { $*ERR.say: "Receieved request: $.request"; }
if $.request ~~ / ^ (\d+) \: / {
if $.debug {
$*ERR.say: "A proper request was received, parsing into an ENV";
}
my $length = +$0;
my $offset = $0.Str.chars + 1;
if ($rlen < $length + $offset) {
return self.err("malformed netstring, length is incorrect.");
}
my $env_string = $.request.substr($offset, $length);
my $comma = $.request.substr($offset+$length, 1);
if $comma ne ',' {
Expand Down

0 comments on commit 72c64e4

Please sign in to comment.