]> granicus.if.org Git - apache/blobdiff - support/logresolve.c
Add CHANGES' security entries for 2.4.27.
[apache] / support / logresolve.c
index d9cd3aa2393df7c52ae0e0e3f0dc59dd687eda25..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);
 }
@@ -138,11 +138,9 @@ int main(int argc, const char * const argv[])
     apr_status_t status;
     const char * arg;
     char * stats = NULL;
-#if APR_MAJOR_VERSION > 1 || (APR_MAJOR_VERSION == 1 && APR_MINOR_VERSION >= 3)
     char * inbuffer;
     char * outbuffer;
-#endif
-    char line[LINE_BUF_SIZE];
+    char * line;
     int doublelookups = 0;
 
     if (apr_app_initialize(&argc, &argv, NULL) != APR_SUCCESS) {
@@ -190,24 +188,23 @@ int main(int argc, const char * const argv[])
     apr_file_open_stdout(&outfile, pool);
     apr_file_open_stdin(&infile, pool);
 
-#if APR_MAJOR_VERSION > 1 || (APR_MAJOR_VERSION == 1 && APR_MINOR_VERSION >= 3)
     /* 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;
     }
 
     /* Set the buffers */
     apr_file_buffer_set(infile, inbuffer, READ_BUF_SIZE);
     apr_file_buffer_set(outfile, outbuffer, WRITE_BUF_SIZE);
-#endif
 
     cache = apr_hash_make(pool);
-    if(apr_pool_create(&pline, NULL) != 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;
@@ -223,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;
         }
@@ -261,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++;
 
@@ -276,7 +273,7 @@ int main(int argc, const char * const argv[])
             /* Add to cache */
             *space = '\0';
             apr_hash_set(cache, line, APR_HASH_KEY_STRING,
-                         apr_pstrdup(pool, line));
+                         apr_pstrdup(apr_hash_pool_get(cache), line));
             continue;
         }
 
@@ -297,7 +294,7 @@ int main(int argc, const char * const argv[])
                 /* Add to cache */
                 *space = '\0';
                 apr_hash_set(cache, line, APR_HASH_KEY_STRING,
-                             apr_pstrdup(pool, line));
+                             apr_pstrdup(apr_hash_pool_get(cache), line));
                 continue;
             }
         }
@@ -307,7 +304,7 @@ int main(int argc, const char * const argv[])
 
         /* Store it in the cache */
         apr_hash_set(cache, line, APR_HASH_KEY_STRING,
-                     apr_pstrdup(pool, hostname));
+                     apr_pstrdup(apr_hash_pool_get(cache), hostname));
 
         apr_pool_clear(pline);
     }
@@ -318,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);