]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix seg fault in Dir during estimate command with no level value
authorKern Sibbald <kern@sibbald.com>
Wed, 13 Aug 2008 14:35:59 +0000 (14:35 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 13 Aug 2008 14:35:59 +0000 (14:35 +0000)
     given. This fixes bug #1140

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

bacula/patches/2.4.2-estimate-cmd.patch [new file with mode: 0644]
bacula/src/dird/ua_cmds.c
bacula/src/version.h
bacula/technotes-2.4

diff --git a/bacula/patches/2.4.2-estimate-cmd.patch b/bacula/patches/2.4.2-estimate-cmd.patch
new file mode 100644 (file)
index 0000000..ff98b54
--- /dev/null
@@ -0,0 +1,80 @@
+
+ This patch fixes the seg faults that occur in the Director if an incorrect
+ estimate command is given -- in particular a level specification without
+ the value.  This fixes bug #1140
+ Apply this patch to Bacula 2.4.2 (and possibly earlier versions) with:
+
+ cd <bacula-source>
+ patch -p0 <2.4.2-estimate-cmd.patch
+ ./configure <your-options>
+ make
+ ...
+ make install
+
+
+  
+Index: src/dird/ua_cmds.c
+===================================================================
+--- src/dird/ua_cmds.c (revision 7469)
++++ src/dird/ua_cmds.c (working copy)
+@@ -1079,17 +1079,31 @@
+           strcasecmp(ua->argk[i], NT_("fd")) == 0) {
+          if (ua->argv[i]) {
+             client = GetClientResWithName(ua->argv[i]);
++            if (!client) {
++               ua->error_msg(_("Client \"%s\" not found.\n"), ua->argv[i]);
++               return 1;
++            }
+             continue;
++         } else {
++            ua->error_msg(_("Client name missing.\n"));
++            return 1;
+          }
+       }
+       if (strcasecmp(ua->argk[i], NT_("job")) == 0) {
+          if (ua->argv[i]) {
+             job = GetJobResWithName(ua->argv[i]);
+-            if (job && !acl_access_ok(ua, Job_ACL, job->name())) {
++            if (!job) {
++               ua->error_msg(_("Job \"%s\" not found.\n"), ua->argv[i]);
++               return 1;
++            }
++            if (!acl_access_ok(ua, Job_ACL, job->name())) {
+                ua->error_msg(_("No authorization for Job \"%s\"\n"), job->name());
+                return 1;
+             }
+             continue;
++         } else {
++            ua->error_msg(_("Job name missing.\n"));
++            return 1;
+          }
+       }
+       if (strcasecmp(ua->argk[i], NT_("fileset")) == 0) {
+@@ -1100,15 +1114,25 @@
+                return 1;
+             }
+             continue;
++         } else {
++            ua->error_msg(_("Fileset name missing.\n"));
++            return 1;
+          }
++
+       }
+       if (strcasecmp(ua->argk[i], NT_("listing")) == 0) {
+          listing = 1;
+          continue;
+       }
+       if (strcasecmp(ua->argk[i], NT_("level")) == 0) {
+-         if (!get_level_from_name(ua->jcr, ua->argv[i])) {
+-            ua->error_msg(_("Level %s not valid.\n"), ua->argv[i]);
++         if (ua->argv[i]) {
++            if (!get_level_from_name(ua->jcr, ua->argv[i])) {
++               ua->error_msg(_("Level \"%s\" not valid.\n"), ua->argv[i]);
++            }
++            continue;
++         } else {
++           ua->error_msg(_("Level value missing.\n"));
++           return 1;
+          }
+          continue;
+       }
index a0fc360d682eb06b6bd174cca1dc332b80a277cd..5130462e80b9e18eaab82b84e3667559a11b5802 100644 (file)
@@ -1079,17 +1079,31 @@ static int estimate_cmd(UAContext *ua, const char *cmd)
           strcasecmp(ua->argk[i], NT_("fd")) == 0) {
          if (ua->argv[i]) {
             client = GetClientResWithName(ua->argv[i]);
+            if (!client) {
+               ua->error_msg(_("Client \"%s\" not found.\n"), ua->argv[i]);
+               return 1;
+            }
             continue;
+         } else {
+            ua->error_msg(_("Client name missing.\n"));
+            return 1;
          }
       }
       if (strcasecmp(ua->argk[i], NT_("job")) == 0) {
          if (ua->argv[i]) {
             job = GetJobResWithName(ua->argv[i]);
-            if (job && !acl_access_ok(ua, Job_ACL, job->name())) {
+            if (!job) {
+               ua->error_msg(_("Job \"%s\" not found.\n"), ua->argv[i]);
+               return 1;
+            }
+            if (!acl_access_ok(ua, Job_ACL, job->name())) {
                ua->error_msg(_("No authorization for Job \"%s\"\n"), job->name());
                return 1;
             }
             continue;
+         } else {
+            ua->error_msg(_("Job name missing.\n"));
+            return 1;
          }
       }
       if (strcasecmp(ua->argk[i], NT_("fileset")) == 0) {
@@ -1100,15 +1114,25 @@ static int estimate_cmd(UAContext *ua, const char *cmd)
                return 1;
             }
             continue;
+         } else {
+            ua->error_msg(_("Fileset name missing.\n"));
+            return 1;
          }
+
       }
       if (strcasecmp(ua->argk[i], NT_("listing")) == 0) {
          listing = 1;
          continue;
       }
       if (strcasecmp(ua->argk[i], NT_("level")) == 0) {
-         if (!get_level_from_name(ua->jcr, ua->argv[i])) {
-            ua->error_msg(_("Level %s not valid.\n"), ua->argv[i]);
+         if (ua->argv[i]) {
+            if (!get_level_from_name(ua->jcr, ua->argv[i])) {
+               ua->error_msg(_("Level \"%s\" not valid.\n"), ua->argv[i]);
+            }
+            continue;
+         } else {
+           ua->error_msg(_("Level value missing.\n"));
+           return 1;
          }
          continue;
       }
index e90bb59fbef939bf639101064c8f04f0490f5acb..2d44e8c0ab6de21ec6dd0748037d96add3bf3540 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "2.4.3"
-#define BDATE   "08 August 2008"
-#define LSMDATE "08Aug08"
+#define BDATE   "12 August 2008"
+#define LSMDATE "12Aug08"
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2008"       /* year for copyright messages in progs */
index e37cd4f5bbb61a6fcbbdb3a11ca266291ce158b7..3156d504b1ff00d79942804508d767762caa3cfc 100644 (file)
@@ -1,6 +1,9 @@
               Technical notes on version 2.4
 
 General:
+12Aug08
+kes  Fix seg fault in Dir during estimate command with no level value
+     given. This fixes bug #1140.
 08Aug08
 kes  Add message to migration job when the target job is already migrated.
      This closes bug #1129.