summaryrefslogtreecommitdiff
path: root/t/quit.t
diff options
context:
space:
mode:
authorDavid Schoen <dave@lyte.id.au>2017-04-07 12:59:22 +1000
committerdormando <dormando@rydia.net>2017-08-24 00:45:09 -0700
commitbac46b38343c15db9c921ea023f01359cff8aced (patch)
treec3ba0190691376b45970e61af66823699d3dfeb5 /t/quit.t
parent6107b922d633c09d0de7f9b86bac209255a172ad (diff)
downloadmemcached-bac46b38343c15db9c921ea023f01359cff8aced.tar.gz
Drop sockets from obviously malicious command strings
For #265
Diffstat (limited to 't/quit.t')
-rw-r--r--t/quit.t29
1 files changed, 29 insertions, 0 deletions
diff --git a/t/quit.t b/t/quit.t
new file mode 100644
index 0000000..e371e35
--- /dev/null
+++ b/t/quit.t
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use strict;
+use Test::More tests => 1;
+use FindBin qw($Bin);
+use lib "$Bin/lib";
+use MemcachedTest;
+
+my $server = new_memcached();
+my $sock = $server->sock;
+
+{
+ print $sock "quit\r\n";
+
+ # Five seconds ought to be enough to get hung up on.
+ my $oldalarmt = alarm(5);
+
+ # Verify we can't read anything.
+ my $bytesread = -1;
+ eval {
+ local $SIG{'ALRM'} = sub { die "timeout" };
+ my $data = "";
+ $bytesread = sysread($sock, $data, 24),
+ };
+ is($bytesread, 0, "Read after quit.");
+
+ # Restore signal stuff.
+ alarm($oldalarmt);
+}