]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorAndreas Gustafsson <source@isc.org>
Sat, 28 Apr 2001 01:16:26 +0000 (01:16 +0000)
committerAndreas Gustafsson <source@isc.org>
Sat, 28 Apr 2001 01:16:26 +0000 (01:16 +0000)
 815. [bug] If a log file was specified with a path separator
character (i.e. "/") in its name and the directory
did not exist, the log file's name was treated as
though it were the directory name. [RT #1189]

CHANGES
lib/isc/log.c

diff --git a/CHANGES b/CHANGES
index a93993e54dd5874be99375d4c82f6beb119ce159..6a9d369df54068a807ebedcbacaf3dc8615188e5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,9 @@
 
+ 815.  [bug]           If a log file was specified with a path separator
+                       character (i.e. "/") in its name and the directory
+                       did not exist, the log file's name was treated as
+                       though it were the directory name. [RT #1189]
+
  814.  [bug]           Socket objects left over from accept() failures
                        were incorrectly destroyed, causing corruption
                        of socket manager data structures.
index 70aef6786c3e7b5eb03b5caf23829979e84ab017..e9d7927d9fb60ec7d9e3b7583e8d92a1ad9f8570 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: log.c,v 1.55.2.1 2001/01/09 22:49:05 bwelling Exp $ */
+/* $Id: log.c,v 1.55.2.2 2001/04/28 01:16:26 gson Exp $ */
 
 /* Principal Authors: DCL */
 
@@ -217,8 +217,8 @@ assignchannel(isc_logconfig_t *lcfg, unsigned int category_id,
 static isc_result_t
 sync_channellist(isc_logconfig_t *lcfg);
 
-static unsigned int
-greatest_version(isc_logchannel_t *channel);
+static isc_result_t
+greatest_version(isc_logchannel_t *channel, int *greatest);
 
 static isc_result_t
 roll_log(isc_logchannel_t *channel);
@@ -1093,8 +1093,8 @@ sync_channellist(isc_logconfig_t *lcfg) {
        return (ISC_R_SUCCESS);
 }
 
-static unsigned int
-greatest_version(isc_logchannel_t *channel) {
+static isc_result_t
+greatest_version(isc_logchannel_t *channel, int *greatestp) {
        /* XXXDCL HIGHLY NT */
        char *basename, *digit_end;
        const char *dirname;
@@ -1119,11 +1119,20 @@ greatest_version(isc_logchannel_t *channel) {
        }
        basenamelen = strlen(basename);
 
-
        isc_dir_init(&dir);
        result = isc_dir_open(&dir, dirname);
+
+       /*
+        * Replace the file separator if it was taken out.
+        */
+       if (basename != FILE_NAME(channel))
+               *(basename - 1) = '/';
+
+       /*
+        * Return if the directory open failed.
+        */
        if (result != ISC_R_SUCCESS)
-               return (0); /* ... and roll_log will likely report an error. */
+               return (result);
 
        while (isc_dir_read(&dir) == ISC_R_SUCCESS) {
                if (dir.entry.length > basenamelen &&
@@ -1131,17 +1140,16 @@ greatest_version(isc_logchannel_t *channel) {
                    dir.entry.name[basenamelen] == '.') {
 
                        version = strtol(&dir.entry.name[basenamelen + 1],
-                                         &digit_end, 10);
+                                        &digit_end, 10);
                        if (*digit_end == '\0' && version > greatest)
                                greatest = version;
                }
        }
        isc_dir_close(&dir);
 
-       if (basename != FILE_NAME(channel))
-               *--basename = '/';
+       *greatestp = ++greatest;
 
-       return (++greatest);
+       return (ISC_R_SUCCESS);
 }
 
 static isc_result_t
@@ -1150,6 +1158,7 @@ roll_log(isc_logchannel_t *channel) {
        char current[FILENAME_MAX + 1];
        char new[FILENAME_MAX + 1];
        const char *path;
+       isc_result_t result;
 
        /*
         * Do nothing (not even excess version trimming) if ISC_LOG_ROLLNEVER
@@ -1167,7 +1176,9 @@ roll_log(isc_logchannel_t *channel) {
         * though the file names are 0 based, so an oldest log of log.1
         * is a greatest_version of 2.
         */
-       greatest = greatest_version(channel);
+       result = greatest_version(channel, &greatest);
+       if (result != ISC_R_SUCCESS)
+               return (result);
 
        /*
         * Now greatest should be set to the highest version number desired.