]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Move initialization of read/write res lock earlier in the code.
authorKern Sibbald <kern@sibbald.com>
Wed, 23 Jan 2008 19:46:04 +0000 (19:46 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 23 Jan 2008 19:46:04 +0000 (19:46 +0000)
     This fixes the crash with a null conf file. This fixes bug
     #1030.
kes  Redefine CURES in lib/parse_conf to be URES and move it all
     into lib/parse_conf.c -- this responds to bug #1042, but does
     not fix it. The fix is not to compile with FORTIFY_SOURCE.
kes  Backport fix de-referencing a NULL pointer in the scanner from
     the trunk SVN. I don't think this was reported as a bug

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@6301 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/lib/parse_conf.c
bacula/src/lib/parse_conf.h
bacula/src/version.h
bacula/technotes-2.1

index 8968853cb208331b2a79b20e98bbb76f14b4651e..c581c422c398126e06468e72132016ed2152269a 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -78,12 +78,20 @@ extern int r_last;
 extern RES_TABLE resources[];
 extern RES **res_head;
 
+/*
+ * Define the Union of all the common resource structure definitions.
+ */
+union URES {
+   MSGS  res_msgs;
+   RES hdr;
+};
+
 #if defined(_MSC_VER)
 // work around visual studio name mangling preventing external linkage since res_all
 // is declared as a different type when instantiated.
-extern "C" CURES res_all;
+extern "C" URES res_all;
 #else
-extern  CURES res_all;
+extern  URES res_all;
 #endif
 extern int res_all_size;
 
@@ -188,19 +196,10 @@ const char *res_to_str(int rcode)
  * Initialize the static structure to zeros, then
  *  apply all the default values.
  */
-void init_resource(int type, RES_ITEM *items, int pass)
+static void init_resource(int type, RES_ITEM *items, int pass)
 {
    int i;
    int rindex = type - r_first;
-   static bool first = true;
-   int errstat;
-
-   if (first && (errstat=rwl_init(&res_lock)) != 0) {
-      berrno be;
-      Emsg1(M_ABORT, 0, _("Unable to initialize resource lock. ERR=%s\n"),
-            be.bstrerror(errstat));
-   }
-   first = false;
 
    memset(&res_all, 0, res_all_size);
    res_all.hdr.rcode = type;
@@ -293,6 +292,7 @@ void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass)
          free_pool_memory(dest);
          Dmsg0(900, "done with dest codes\n");
          break;
+
       case MD_FILE:                /* file */
       case MD_APPEND:              /* append */
          dest = get_pool_memory(PM_MESSAGE);
@@ -790,6 +790,15 @@ parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error, int err_type)
    enum parse_state state = p_none;
    RES_ITEM *items = NULL;
    int level = 0;
+   static bool first = true;
+   int errstat;
+
+   if (first && (errstat=rwl_init(&res_lock)) != 0) {
+      berrno be;
+      Emsg1(M_ABORT, 0, _("Unable to initialize resource lock. ERR=%s\n"),
+            be.bstrerror(errstat));
+   }
+   first = false;
 
    char *full_path = (char *)alloca(MAX_PATH + 1);
 
@@ -823,7 +832,8 @@ parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error, int err_type)
       }
       lex_set_error_handler_error_type(lc, err_type) ;
       while ((token=lex_get_token(lc, T_ALL)) != T_EOF) {
-         Dmsg1(900, "parse got token=%s\n", lex_tok_to_str(token));
+         Dmsg3(900, "parse state=%d pass=%d got token=%s\n", state, pass,
+              lex_tok_to_str(token));
          switch (state) {
          case p_none:
             if (token == T_EOL) {
@@ -841,8 +851,11 @@ parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error, int err_type)
             }
             for (i=0; resources[i].name; i++) {
                if (strcasecmp(resources[i].name, lc->str) == 0) {
-                  state = p_resource;
                   items = resources[i].items;
+                  if (!items) {
+                     break;
+                  }
+                  state = p_resource;
                   res_type = resources[i].rcode;
                   init_resource(res_type, items, pass);
                   break;
index 470ac528184c3120a2eae3a30fbaa0b231eb165c..3e630b55fc198a9a7c043b45256500c4a08caa2c 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -116,16 +116,6 @@ public:
 
 inline char *MSGS::name() const { return hdr.name; }
 
-
-/* Define the Union of all the above common
- * resource structure definitions.
- */
-union CURES {
-   MSGS  res_msgs;
-   RES hdr;
-};
-
-
 /* Configuration routines */
 int   parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error = NULL, int err_type=M_ERROR_TERM);
 void    free_config_resources(void);
index fc8dbcde624a66c91c8e88145b4a0d3c1bd4e7a5..edbfe091b9faff3533a717e7100450d3c499146f 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "2.2.8"
-#define BDATE   "08 January 2008"
-#define LSMDATE "08Jan08"
+#define BDATE   "24 January 2008"
+#define LSMDATE "24Jan08"
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2008"       /* year for copyright messages in progs */
index a3fdb02b7d904cfb9dd104d75f6cf0ca02658987..454820fba805aaddade13eaac5dd5ee0c0d4d585 100644 (file)
@@ -1,6 +1,17 @@
               Technical notes on version 2.2
 
 General:
+Release Version 2.2.8
+23Jan08
+kes  Move initialization of read/write res lock earlier in the code.
+     This fixes the crash with a null conf file. This fixes bug
+     #1030.
+kes  Redefine CURES in lib/parse_conf to be URES and move it all
+     into lib/parse_conf.c -- this responds to bug #1042, but does
+     not fix it. The fix is not to compile with FORTIFY_SOURCE.
+kes  Backport fix de-referencing a NULL pointer in the scanner from
+     the trunk SVN. I don't think this was reported as a bug.
+
 Beta release Version 2.2.8
 09Jan08
 kes  Re-enable the new job code editing (%f).