]> mj.ucw.cz Git - subauth.git/blobdiff - server/cmd.c
Server: Maximum comment size is limited (configurable)
[subauth.git] / server / cmd.c
index 28ec103baf920f7bd3a089c526c40aec4167ff44..106d1ef142be01c55d99bed9bc57368b14f4b413 100644 (file)
@@ -260,8 +260,12 @@ static void cmd_create_token(struct client *c)
   if (clist_size(&aa->tokens) >= aa->zone->allow_tokens)
     cmd_error(c, "Maximum number of tokens was reached");
 
+  const char *comment = get_string(c->request, "comment");
+  if (comment && strlen(comment) > max_comment_size)
+    cmd_error(c, "Comment too long");
+
   struct auth_token *at = auth_create_token(aa);
-  char *tok = auth_set_token_generated(at, get_string(c->request, "comment"), c->pool);
+  char *tok = auth_set_token_generated(at, comment, c->pool);
   set_string(c, c->reply, "token", tok);
 
   msg(L_INFO, "Created token: login=<%s> zone=<%s> id=<%s>", aa->user->login, aa->zone->name, at->ident);