Browse Source

* Check that bot is valid in cmd_groups

Bryan Drewery 14 năm trước cách đây
mục cha
commit
aa7fd7a2e2
3 tập tin đã thay đổi với 8 bổ sung5 xóa
  1. 5 0
      src/cmds.c
  2. 2 4
      src/userrec.c
  3. 1 1
      src/users.h

+ 5 - 0
src/cmds.c

@@ -908,6 +908,11 @@ static void cmd_groups(int idx, char *par)
   putlog(LOG_CMDS, "*", "#%s# groups %s", dcc[idx].nick, par);
   bd::String botnick(newsplit(&par));
 
+  if (botnick.length() && !get_user_by_handle(userlist, botnick.c_str())) {
+    dprintf(idx, "No such bot.\n");
+    return;
+  }
+
   bd::Array<bd::String> globalgroups = bd::String(var_get_gdata("groups")).split(",");
   bd::Array<bd::String> allgroups;
   bd::HashTable<bd::String, bd::Array<bd::String> > groupBots;

+ 2 - 4
src/userrec.c

@@ -77,7 +77,7 @@ int count_users(struct userrec *bu)
   return tot;
 }
 
-static struct userrec *check_dcclist_hand(char *handle)
+static struct userrec *check_dcclist_hand(const char *handle)
 {
   for (int i = 0; i < dcc_total; i++)
     if (dcc[i].type && !strcasecmp(dcc[i].nick, handle))
@@ -103,13 +103,11 @@ struct userrec *host_conflicts(char *host)
   return NULL;
 }
 
-struct userrec *get_user_by_handle(struct userrec *bu, char *handle)
+struct userrec *get_user_by_handle(struct userrec *bu, const char *handle)
 {
   if (!handle)
     return NULL;
 
-  /* FIXME: This should be done outside of this function. */
-  rmspace(handle);
   if (!handle[0] || (handle[0] == '*'))
     return NULL;
 

+ 1 - 1
src/users.h

@@ -147,7 +147,7 @@ extern struct igrec *global_ign;
  * Note: Flags are in eggdrop.h
  */
 
-struct userrec *get_user_by_handle(struct userrec *, char *);
+struct userrec *get_user_by_handle(struct userrec *, const char *);
 struct userrec *get_user_by_host(char *);
 struct userrec *check_chanlist(const char *);
 struct userrec *check_chanlist_hand(const char *);