From: Kern Sibbald Date: Wed, 13 Aug 2008 14:35:59 +0000 (+0000) Subject: Fix seg fault in Dir during estimate command with no level value X-Git-Tag: Release-2.4.3~27 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f3b180c4abd275568859f79d8242719adec44f79;p=bacula%2Fbacula Fix seg fault in Dir during estimate command with no level value 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 --- diff --git a/bacula/patches/2.4.2-estimate-cmd.patch b/bacula/patches/2.4.2-estimate-cmd.patch new file mode 100644 index 0000000000..ff98b5447e --- /dev/null +++ b/bacula/patches/2.4.2-estimate-cmd.patch @@ -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 + patch -p0 <2.4.2-estimate-cmd.patch + ./configure + 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; + } diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index a0fc360d68..5130462e80 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -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; } diff --git a/bacula/src/version.h b/bacula/src/version.h index e90bb59fbe..2d44e8c0ab 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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 */ diff --git a/bacula/technotes-2.4 b/bacula/technotes-2.4 index e37cd4f5bb..3156d504b1 100644 --- a/bacula/technotes-2.4 +++ b/bacula/technotes-2.4 @@ -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.