]> granicus.if.org Git - apache/blobdiff - support/logresolve.c
Add CHANGES' security entries for 2.4.27.
[apache] / support / logresolve.c
index c746bb5f3721fc8c77f0bcb79f8266b096c4d67f..87df4e82e8cda81fcf67f7e9ef5482852f109c0d 100644 (file)
@@ -68,9 +68,9 @@
 #include <stdlib.h>
 #endif
 
-#define READ_BUF_SIZE 10240
-#define WRITE_BUF_SIZE 10240
-#define LINE_BUF_SIZE 2048
+#define READ_BUF_SIZE  128*1024
+#define WRITE_BUF_SIZE 128*1024
+#define LINE_BUF_SIZE  128*1024
 
 static apr_file_t *errfile;
 static const char *shortname = "logresolve";
@@ -122,7 +122,7 @@ static void usage(void)
     "Options:"                                                               NL
     "  -s   Record statistics to STATFILE when finished."                    NL
                                                                              NL
-    "  -c   Perform double lookups when resolving IP addresses."            NL,
+    "  -c   Perform double lookups when resolving IP addresses."             NL,
     shortname, shortname);
     exit(1);
 }
@@ -140,7 +140,7 @@ int main(int argc, const char * const argv[])
     char * stats = NULL;
     char * inbuffer;
     char * outbuffer;
-    char line[LINE_BUF_SIZE];
+    char * line;
     int doublelookups = 0;
 
     if (apr_app_initialize(&argc, &argv, NULL) != APR_SUCCESS) {
@@ -189,8 +189,9 @@ int main(int argc, const char * const argv[])
     apr_file_open_stdin(&infile, pool);
 
     /* Allocate two new 10k file buffers */
-    if ((outbuffer = apr_palloc(pool, WRITE_BUF_SIZE)) == NULL ||
-        (inbuffer = apr_palloc(pool, READ_BUF_SIZE)) == NULL) {
+    if (   (outbuffer = apr_palloc(pool, WRITE_BUF_SIZE)) == NULL
+        || (inbuffer  = apr_palloc(pool, READ_BUF_SIZE))  == NULL
+        || (line      = apr_palloc(pool, LINE_BUF_SIZE))  == NULL) {
         return 1;
     }
 
@@ -199,11 +200,11 @@ int main(int argc, const char * const argv[])
     apr_file_buffer_set(outfile, outbuffer, WRITE_BUF_SIZE);
 
     cache = apr_hash_make(pool);
-    if(apr_pool_create(&pline, pool) != APR_SUCCESS){
+    if (apr_pool_create(&pline, pool) != APR_SUCCESS) {
         return 1;
     }
 
-    while (apr_file_gets(line, sizeof(line), infile) == APR_SUCCESS) {
+    while (apr_file_gets(line, LINE_BUF_SIZE, infile) == APR_SUCCESS) {
         char *hostname;
         char *space;
         apr_sockaddr_t *ip;
@@ -219,7 +220,7 @@ int main(int argc, const char * const argv[])
 
         /* Check if this could even be an IP address */
         if (!apr_isxdigit(line[0]) && line[0] != ':') {
-                withname++;
+            withname++;
             apr_file_puts(line, outfile);
             continue;
         }
@@ -257,7 +258,7 @@ int main(int argc, const char * const argv[])
         resolves++;
 
         /* From here on our we cache each result, even if it was not
-         * succesful
+         * successful
          */
         cachesize++;
 
@@ -314,7 +315,7 @@ int main(int argc, const char * const argv[])
     if (stats) {
         apr_file_t *statsfile;
         if (apr_file_open(&statsfile, stats,
-                       APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE,
+                          APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE,
                           APR_OS_DEFAULT, pool) != APR_SUCCESS) {
             apr_file_printf(errfile, "%s: Could not open %s for writing.",
                             shortname, stats);