Skip to content

Commit

Permalink
Fix: validate publish message correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
muzzammilshahid committed Jun 3, 2024
1 parent 6da20a4 commit 42f7df9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions lib/src/acceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import "package:pinenacl/ed25519.dart";
import "package:wampproto/auth.dart";
import "package:wampproto/messages.dart";
import "package:wampproto/serializers.dart";
import "package:wampproto/src/auth/auth.dart";
import "package:wampproto/src/exception.dart";
import "package:wampproto/src/types.dart";
import "package:wampproto/src/uris.dart";
Expand All @@ -27,7 +26,7 @@ class Acceptor {
static const int stateHelloReceived = 1;
static const int stateChallengeSent = 2;
static const int stateWelcomeSent = 3;
static const int stateAbort = 4;
static const int stateAborted = 4;

static const String ticket = "ticket";
static const String wampcra = "wampcra";
Expand Down Expand Up @@ -135,7 +134,7 @@ class Acceptor {
case cryptosign:
var isVerified = verifyCryptoSignSignature(msg.signature, Base16Encoder.instance.decode(_publicKey));
if (!isVerified) {
_state = stateAbort;
_state = stateAborted;
return Abort(AbortFields({}, errAuthenticationFailed));
}
_state = stateWelcomeSent;
Expand All @@ -150,7 +149,7 @@ class Acceptor {
case wampcra:
var isVerified = verifyWampCRASignature(msg.signature, _challenge, Uint8List.fromList(_secret.codeUnits));
if (!isVerified) {
_state = stateAbort;
_state = stateAborted;
return Abort(AbortFields({}, errAuthenticationFailed));
}
_state = stateWelcomeSent;
Expand All @@ -175,7 +174,7 @@ class Acceptor {
return welcome;
}
} else if (msg is Abort) {
_state = stateAbort;
_state = stateAborted;

return null;
} else {
Expand All @@ -186,7 +185,7 @@ class Acceptor {
}

bool isAborted() {
return _state == stateAbort;
return _state == stateAborted;
}

SessionDetails getSessionDetails() {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/messages/publish.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class Publish implements Message {
message: text,
spec: {
1: validateRequestID,
2: validateURI,
3: validateOptions,
2: validateOptions,
3: validateURI,
4: validateArgs,
5: validateKwargs,
},
Expand Down

0 comments on commit 42f7df9

Please sign in to comment.