Przeglądaj źródła

* Large buffers

svn: 872
Bryan Drewery 22 lat temu
rodzic
commit
aaf3e2f0b4
5 zmienionych plików z 22 dodań i 13 usunięć
  1. 1 1
      src/conf.c
  2. 9 6
      src/crypt.c
  3. 2 1
      src/mod/channels.mod/tclchan.c
  4. 2 1
      src/mod/irc.mod/mode.c
  5. 8 4
      src/shell.c

+ 1 - 1
src/conf.c

@@ -416,7 +416,7 @@ int readconf(char *cfile, int bits)
 {
   FILE *f = NULL;
   int i = 0, enc = (bits & CONF_ENC) ? 1 : 0;
-  char inbuf[8192] = "";
+  char inbuf[201] = "";
 
   sdprintf("readconf(%s, %d)", cfile, enc);
   Context;

+ 9 - 6
src/crypt.c

@@ -173,9 +173,10 @@ void encrypt_pass(char *s1, char *s2)
 int lfprintf (FILE *stream, ...)
 {
   va_list va;
-  char buf[8192] = "", *ln = NULL, *nln = NULL, *tmp = NULL, *format = NULL;
+  char buf[8192], *ln = NULL, *nln = NULL, *tmp = NULL, *format = NULL;
   int res;
 
+  buf[0] = 0;
   va_start(va, stream);
   format = va_arg(va, char *);
   egg_vsnprintf(buf, sizeof buf, format, va);
@@ -198,7 +199,7 @@ int lfprintf (FILE *stream, ...)
 
 void Encrypt_File(char *infile, char *outfile)
 {
-  char  buf[8192] = "";
+  char  buf[8192];
   FILE *f = NULL, *f2 = NULL;
   int std = 0;
 
@@ -215,7 +216,8 @@ void Encrypt_File(char *infile, char *outfile)
     printf("----------------------------------START----------------------------------\n");
   }
 
-  while (fscanf(f,"%[^\n]\n",buf) != EOF) {
+  buf[0] = 0;
+  while (fscanf(f, "%[^\n]\n", buf) != EOF) {
     if (std)
       printf("%s\n", encrypt_string(SALT1, buf));
     else
@@ -231,7 +233,7 @@ void Encrypt_File(char *infile, char *outfile)
 
 void Decrypt_File(char *infile, char *outfile)
 {
-  char buf[8192] = "", *temps = NULL;
+  char buf[8192], *temps = NULL;
   FILE *f = NULL, *f2 = NULL;
   int std = 0;
 
@@ -247,8 +249,9 @@ void Decrypt_File(char *infile, char *outfile)
   } else {
     printf("----------------------------------START----------------------------------\n");
   }
-
-  while (fscanf(f,"%[^\n]\n",buf) != EOF) {
+  
+  buf[0] = 0;
+  while (fscanf(f, "%[^\n]\n", buf) != EOF) {
     temps = (char *) decrypt_string(SALT1, buf);
     if (!std)
       fprintf(f2, "%s\n",temps);

+ 2 - 1
src/mod/channels.mod/tclchan.c

@@ -734,7 +734,7 @@ int channel_add(char *result, char *newname, char *options)
 {
   struct chanset_t *chan = NULL;
   int items = 0, ret = OK, join = 0;
-  char buf[3001] = "";
+  char buf[3001];
   const char **item = NULL;
 
   if (!newname || !newname[0] || !strchr(CHANMETA, newname[0])) {
@@ -748,6 +748,7 @@ int channel_add(char *result, char *newname, char *options)
       sprintf(result, "invalid channel name");
     return ERROR;
   }
+  buf[0] = 0;
   simple_sprintf(buf, "chanmode { %s } ", glob_chanmode);
   strcat(buf, glob_chanset);
   strcat(buf, cfg_glob_chanset);

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

@@ -185,9 +185,10 @@ static void flush_mode(struct chanset_t *chan, int pri)
 }
 
 void dequeue_op_deop(struct chanset_t * chan) {
-  char lines[4096] = "", modechars[10] = "", nicks[128] = "";
+  char lines[4096], modechars[10] = "", nicks[128] = "";
   int i = 0, cnt = 0;
 
+  lines[0] = 0;
   while ((i < 20) && (chan->opqueue[i].target)) {
     strcat(nicks, " ");
     strcat(nicks, chan->opqueue[i].target);

+ 8 - 4
src/shell.c

@@ -210,10 +210,14 @@ void check_processes()
             while (*p != ' ')
               *p++ = 1;
           } else {
-            char wrk[16384] = "";
-
-            egg_snprintf(wrk, sizeof wrk, "Unexpected process: %s", line);
-            detected(DETECT_PROCESS, wrk);
+            char *work = NULL;
+            size_t size = 0;
+
+            size = strlen(line) + 22;
+            work = calloc(1, size);
+            egg_snprintf(work, size, "Unexpected process: %s", line);
+            detected(DETECT_PROCESS, work);
+            free(work);
           }
         }
       }