forked from memcached/memcached
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: fix ascii auth bug with missing newlines
If a user supplies an authfile to -Y with a single user:pass and no newline, we were cutting the final character of the password and failing to authenticate.
- Loading branch information
Showing
4 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env perl | ||
# Testing for single-line authfiles with no newline at the end. | ||
|
||
use strict; | ||
use Test::More tests => 4; | ||
use FindBin qw($Bin); | ||
use lib "$Bin/lib"; | ||
use MemcachedTest; | ||
|
||
my $server = new_memcached("-Y $Bin/authfile2 -U 0"); | ||
my $sock = $server->sock; | ||
|
||
# Fail to authenticate. | ||
print $sock "set foo 0 0 7\r\nfoo bab\r\n"; | ||
like(scalar <$sock>, qr/CLIENT_ERROR/, "failed to authenticate"); | ||
|
||
# Try for real. | ||
print $sock "set foo 0 0 7\r\nfoo bar\r\n"; | ||
like(scalar <$sock>, qr/STORED/, "authenticated?"); | ||
|
||
print $sock "set toast 0 0 2\r\nhi\r\n"; | ||
like(scalar <$sock>, qr/STORED/, "stored an item that didn't look like user/pass"); | ||
|
||
mem_get_is($sock, "toast", "hi"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo:bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters