Pārlūkot izejas kodu

* Fixed a potential segfault in the update code

svn: 1723
Bryan Drewery 21 gadi atpakaļ
vecāks
revīzija
a42588aa79
1 mainītis faili ar 8 papildinājumiem un 9 dzēšanām
  1. 8 9
      src/mod/update.mod/update.c

+ 8 - 9
src/mod/update.mod/update.c

@@ -186,18 +186,17 @@ static void got_nu(char *botnick, char *code, char *par)
 
 
    if (newts > buildts) {
    if (newts > buildts) {
 #ifdef LEAF
 #ifdef LEAF
-     struct bot_addr *bi = NULL, *obi = NULL;
-
-     obi = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, conf.bot->u);
-     bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));
+     struct bot_addr *obi = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, conf.bot->u);
+     struct bot_addr *bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));
 
 
      bi->uplink = strdup(botnick);
      bi->uplink = strdup(botnick);
-     bi->address = strdup(obi->address);
-     bi->telnet_port = obi->telnet_port;
-     bi->relay_port = obi->relay_port;
-     bi->hublevel = obi->hublevel;
+     if (obi) {
+       bi->address = strdup(obi->address);
+       bi->telnet_port = obi->telnet_port;
+       bi->relay_port = obi->relay_port;
+       bi->hublevel = obi->hublevel;
+     } 
      set_user(&USERENTRY_BOTADDR, conf.bot->u, bi);
      set_user(&USERENTRY_BOTADDR, conf.bot->u, bi);
-
    /* Change our uplink to them */
    /* Change our uplink to them */
    /* let cont_link restructure us.. */
    /* let cont_link restructure us.. */
      putlog(LOG_MISC, "*", "Changed uplink to %s for update.", botnick);
      putlog(LOG_MISC, "*", "Changed uplink to %s for update.", botnick);