From: Kern Sibbald Date: Fri, 22 Dec 2006 15:40:16 +0000 (+0000) Subject: kes Fix code to check for two resources of same name. It forgot X-Git-Tag: Release-7.0.0~7190 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=306f4ac1284013a382baf5b69381f060ce910d5c;p=bacula%2Fbacula kes Fix code to check for two resources of same name. It forgot to check the last entry. Fixes bug #734. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3843 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/console/console_conf.c b/bacula/src/console/console_conf.c index 125a2a7ec6..a65dfb841d 100644 --- a/bacula/src/console/console_conf.c +++ b/bacula/src/console/console_conf.c @@ -310,15 +310,16 @@ void save_resource(int type, RES_ITEM *items, int pass) if (!res_head[rindex]) { res_head[rindex] = (RES *)res; /* store first entry */ } else { - RES *next; - for (next=res_head[rindex]; next->next; next=next->next) { + RES *next, *last; + for (last=next=res_head[rindex]; next; next=next->next) { + last = next; if (strcmp(next->name, res->res_dir.hdr.name) == 0) { Emsg2(M_ERROR_TERM, 0, _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), resources[rindex].name, res->res_dir.hdr.name); } } - next->next = (RES *)res; + last->next = (RES *)res; Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), res->res_dir.hdr.name); } diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 74db53766c..b32c412208 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -1375,7 +1375,7 @@ void save_resource(int type, RES_ITEM *items, int pass) error = true; break; default: - printf(_("Unknown resource type %d in save_resrouce.\n"), type); + printf(_("Unknown resource type %d in save_resource.\n"), type); error = true; break; } @@ -1388,20 +1388,21 @@ void save_resource(int type, RES_ITEM *items, int pass) Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type), res->res_dir.hdr.name, rindex); } else { - RES *next; + RES *next, *last; if (res->res_dir.hdr.name == NULL) { Emsg1(M_ERROR_TERM, 0, _("Name item is required in %s resource, but not found.\n"), resources[rindex]); } /* Add new res to end of chain */ - for (next=res_head[rindex]; next->next; next=next->next) { + for (last=next=res_head[rindex]; next; next=next->next) { + last = next; if (strcmp(next->name, res->res_dir.hdr.name) == 0) { Emsg2(M_ERROR_TERM, 0, _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), resources[rindex].name, res->res_dir.hdr.name); } } - next->next = (RES *)res; + last->next = (RES *)res; Dmsg4(900, _("Inserting %s res: %s index=%d pass=%d\n"), res_to_str(type), res->res_dir.hdr.name, rindex, pass); } diff --git a/bacula/src/filed/filed_conf.c b/bacula/src/filed/filed_conf.c index 0bcb3129ce..416f9ecc84 100644 --- a/bacula/src/filed/filed_conf.c +++ b/bacula/src/filed/filed_conf.c @@ -423,16 +423,17 @@ void save_resource(int type, RES_ITEM *items, int pass) if (!res_head[rindex]) { res_head[rindex] = (RES *)res; /* store first entry */ } else { - RES *next; + RES *next, *last; /* Add new res to end of chain */ - for (next=res_head[rindex]; next->next; next=next->next) { + for (last=next=res_head[rindex]; next; next=next->next) { + last = next; if (strcmp(next->name, res->res_dir.hdr.name) == 0) { Emsg2(M_ERROR_TERM, 0, _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), resources[rindex].name, res->res_dir.hdr.name); } } - next->next = (RES *)res; + last->next = (RES *)res; Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), res->res_dir.hdr.name); } diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index 80dd822092..ec5632a41a 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -659,16 +659,17 @@ void save_resource(int type, RES_ITEM *items, int pass) if (!res_head[rindex]) { res_head[rindex] = (RES *)res; /* store first entry */ } else { - RES *next; + RES *next, *last; /* Add new res to end of chain */ - for (next=res_head[rindex]; next->next; next=next->next) { + for (last=next=res_head[rindex]; next; next=next->next) { + last = next; if (strcmp(next->name, res->res_dir.hdr.name) == 0) { Emsg2(M_ERROR_TERM, 0, _("Attempt to define second \"%s\" resource named \"%s\" is not permitted.\n"), resources[rindex].name, res->res_dir.hdr.name); } } - next->next = (RES *)res; + last->next = (RES *)res; Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), res->res_dir.hdr.name); } diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index dfc635a9b7..e247791827 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -2,6 +2,8 @@ General: 22Dec06 +kes Fix code to check for two resources of same name. It forgot + to check the last entry. Fixes bug #734. kes Apply scanvolume patch from Richard Mortimer that fixes bug #738. kes Apply Eric's patch for recycling the Scratch pool.