From cbdaf465925652bf9a412606607b9ce7630c7f42 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 25 Apr 2023 09:51:37 +0200 Subject: [PATCH] service: reject params for commands that don't take any We were already rejecting extraneous params for commands that take one or more. --- service.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/service.go b/service.go index acd9e41..1d11501 100644 --- a/service.go +++ b/service.go @@ -593,6 +593,10 @@ func handleServiceNetworkCreate(ctx *serviceContext, params []string) error { } func handleServiceNetworkStatus(ctx *serviceContext, params []string) error { + if len(params) != 0 { + return fmt.Errorf("expected no argument") + } + n := 0 for _, net := range ctx.user.networks { var statuses []string @@ -897,6 +901,10 @@ func handleServiceSASLReset(ctx *serviceContext, params []string) error { } func handleUserStatus(ctx *serviceContext, params []string) error { + if len(params) != 0 { + return fmt.Errorf("expected no argument") + } + // Limit to a small amount of users to avoid sending // thousands of messages on large instances. users := make([]database.User, 0, 50) @@ -1439,6 +1447,10 @@ func handleServiceChannelDelete(ctx *serviceContext, params []string) error { } func handleServiceServerStatus(ctx *serviceContext, params []string) error { + if len(params) != 0 { + return fmt.Errorf("expected no argument") + } + dbStats, err := ctx.srv.db.Stats(ctx) if err != nil { return err