Ver Fonte

* Ported [2834] to 1.2.10
* Fixed a sharing segfault with an empty userfile. (fixes #243)


svn: 2835

Bryan Drewery há 20 anos atrás
pai
commit
b590c3c6ee
4 ficheiros alterados com 34 adições e 23 exclusões
  1. 1 0
      doc/UPDATES
  2. 27 20
      src/chanprog.c
  3. 2 0
      src/chanprog.h
  4. 4 3
      src/mod/share.mod/share.c

+ 1 - 0
doc/UPDATES

@@ -22,6 +22,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * cmd_checkchannels now states if a bot is not online. (fixes #239)
 * Added mIRC 6.17 version reply
 * Fixed empty version replies. (fixes #236)
+* Fixed a sharing segfault with an empty userfile. (fixes #243)
 
 1.2.9 - http://tracker.shatow.net/milestone/1.2.9
 * Fixed cmd_[un]stick not properly using numbers for channel masks. (#160)

+ 27 - 20
src/chanprog.c

@@ -513,28 +513,9 @@ void load_internal_users()
 
 }
 
-void chanprog()
-{
-  struct utsname un;
+void add_myself_to_userlist() {
   struct bot_addr *bi = NULL;
 
-  /* cache our ip on load instead of every 30 seconds */
-  cache_my_ip();
-  sdprintf("ip4: %s", myipstr(4));
-  sdprintf("ip6: %s", myipstr(6));
-  sdprintf("I am: %s", conf.bot->nick);
-  if (conf.bot->hub) {
-    simple_snprintf(userfile, 121, "%s/.u", conf.binpath);
-    loading = 1;
-    checkchans(0);
-    readuserfile(userfile, &userlist);
-    checkchans(1);
-    var_parse_my_botset();
-    loading = 0;
-  }
-
-  load_internal_users();
-
   if (!(conf.bot->u = get_user_by_handle(userlist, conf.bot->nick))) {
     /* I need to be on the userlist... doh. */
     userlist = adduser(userlist, conf.bot->nick, "none", "-", USER_OP, 1);
@@ -555,7 +536,33 @@ void chanprog()
 
   if (!bi)
     fatal("I'm added to userlist but without a bot record!", 0);
+}
+
+void chanprog()
+{
+  struct utsname un;
+
+  /* cache our ip on load instead of every 30 seconds */
+  cache_my_ip();
+  sdprintf("ip4: %s", myipstr(4));
+  sdprintf("ip6: %s", myipstr(6));
+  sdprintf("I am: %s", conf.bot->nick);
+  if (conf.bot->hub) {
+    simple_snprintf(userfile, 121, "%s/.u", conf.binpath);
+    loading = 1;
+    checkchans(0);
+    readuserfile(userfile, &userlist);
+    checkchans(1);
+    var_parse_my_botset();
+    loading = 0;
+  }
+
+  load_internal_users();
+
+  add_myself_to_userlist();
+
   if (conf.bot->hub) {
+    struct bot_addr *bi = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, conf.bot->u);
     listen_all(bi->telnet_port, 0);
     my_port = bi->telnet_port;
   }

+ 2 - 0
src/chanprog.h

@@ -24,6 +24,8 @@ void clear_chanlist_member(const char *nick);
 int botshouldjoin(struct userrec *u, struct chanset_t *);
 int shouldjoin(struct chanset_t *);
 char *samechans(const char *, const char *);
+void add_myself_to_userlist();
+void load_internal_users();
 
 extern struct chanset_t		*chanset;
 extern char			admin[], origbotname[NICKLEN + 1], botname[];

+ 4 - 3
src/mod/share.mod/share.c

@@ -1305,9 +1305,10 @@ finish_share(int idx)
    */
   clear_userlist(ou);
 
-  if (!conf.bot->u)
-    conf.bot->u = get_user_by_handle(userlist, conf.bot->nick);
-
+  /* The userfile we received may just be bogus or missing important users */
+  load_internal_users();
+  add_myself_to_userlist();
+  
   /* Our hostmask may have been updated on connect, but the new userfile may not have it. */
   check_hostmask();