bug fix for _SYS.

This commit is contained in:
Derek Collison
2016-06-16 21:46:54 -07:00
parent a55b7c2744
commit 248bd8d366
2 changed files with 8 additions and 2 deletions

View File

@@ -876,8 +876,9 @@ func (c *client) processMsg(msg []byte) {
}
// Disallow publish to _SYS.>, these are reserved for internals.
if c.pa.subject[0] == '_' && c.pa.subject[1] == 'S' &&
c.pa.subject[2] == 'Y' && c.pa.subject[3] == 'S' {
if c.pa.subject[0] == '_' && len(c.pa.subject) > 4 &&
c.pa.subject[1] == 'S' && c.pa.subject[2] == 'Y' &&
c.pa.subject[3] == 'S' && c.pa.subject[4] == '.' {
c.pubPermissionViolation(c.pa.subject)
return
}

View File

@@ -29,6 +29,11 @@ func TestUserAuthorizationProto(t *testing.T) {
// Check that we now reserve _SYS.> though for internal, so no clients.
sendProto(t, c, "PUB _SYS.HB 2\r\nok\r\n")
expectResult(t, c, permErrRe)
// Check that _ is ok
sendProto(t, c, "PUB _ 2\r\nok\r\n")
expectResult(t, c, okRe)
c.Close()
// Bob is a requestor only, e.g. req.foo, req.bar for publish, subscribe only to INBOXes.