From: Kern Sibbald Date: Sun, 23 Dec 2007 12:14:54 +0000 (+0000) Subject: Work on Dir seg fault reported by Frank Sweetser X-Git-Tag: Release-2.2.7~5^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c72e73ca0bb2dd0ee707638d69e0792203b3ce83;p=bacula%2Fbacula Work on Dir seg fault reported by Frank Sweetser git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@6108 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 9b0dc9090d..06287fcd2e 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -233,7 +233,7 @@ int restore_cmd(UAContext *ua, const char *cmd) escaped_where_name = escape_filename(rx.RegexWhere); Mmsg(ua->cmd, "run job=\"%s\" client=\"%s\" restoreclient=\"%s\" storage=\"%s\"" - " bootstrap=\"%s\" regexwhere=\"%s\" files=%d catalog=\"%s\"", + " bootstrap=\"%s\" regexwhere=\"%s\" files=%u catalog=\"%s\"", job->name(), rx.ClientName, rx.RestoreClientName, rx.store?rx.store->name():"", escaped_bsr_name ? escaped_bsr_name : jcr->RestoreBootstrap, @@ -244,7 +244,7 @@ int restore_cmd(UAContext *ua, const char *cmd) escaped_where_name = escape_filename(rx.where); Mmsg(ua->cmd, "run job=\"%s\" client=\"%s\" restoreclient=\"%s\" storage=\"%s\"" - " bootstrap=\"%s\" where=\"%s\" files=%d catalog=\"%s\"", + " bootstrap=\"%s\" where=\"%s\" files=%u catalog=\"%s\"", job->name(), rx.ClientName, rx.RestoreClientName, rx.store?rx.store->name():"", escaped_bsr_name ? escaped_bsr_name : jcr->RestoreBootstrap, @@ -254,7 +254,7 @@ int restore_cmd(UAContext *ua, const char *cmd) } else { Mmsg(ua->cmd, "run job=\"%s\" client=\"%s\" restoreclient=\"%s\" storage=\"%s\"" - " bootstrap=\"%s\" files=%d catalog=\"%s\"", + " bootstrap=\"%s\" files=%u catalog=\"%s\"", job->name(), rx.ClientName, rx.RestoreClientName, rx.store?rx.store->name():"", escaped_bsr_name ? escaped_bsr_name : jcr->RestoreBootstrap, diff --git a/bacula/src/lib/bsnprintf.c b/bacula/src/lib/bsnprintf.c index 920fdb1b24..e2a05f6b62 100644 --- a/bacula/src/lib/bsnprintf.c +++ b/bacula/src/lib/bsnprintf.c @@ -77,7 +77,7 @@ static int32_t fmtfp(char *buffer, int32_t currlen, int32_t maxlen, #define fmtfp(b, c, m, f, min, max, fl) currlen #endif -#define outch(c) {int len=currlen; if (currlen++ < maxlen) { buffer[len] = (c);}} +#define outch(c) {if (currlen < maxlen) { buffer[currlen++] = (c);}} /* format read states */ @@ -152,9 +152,9 @@ int bvsnprintf(char *buffer, int32_t maxlen, const char *format, va_list args) *buffer = 0; while (state != DP_S_DONE) { - if ((ch == '\0') || (currlen >= maxlen)) + if ((ch == '\0') || (currlen >= maxlen)) { state = DP_S_DONE; - + } switch (state) { case DP_S_DEFAULT: if (ch == '%') { @@ -444,11 +444,12 @@ static int32_t fmtint(char *buffer, int32_t currlen, int32_t maxlen, { int signvalue = 0; uint64_t uvalue; - char convert[20]; + char convert[25]; int place = 0; int spadlen = 0; /* amount to space pad */ int zpadlen = 0; /* amount to zero pad */ int caps = 0; + const char *cvt_string; if (max < 0) { max = 0; @@ -471,12 +472,12 @@ static int32_t fmtint(char *buffer, int32_t currlen, int32_t maxlen, caps = 1; /* Should characters be upper case? */ } + cvt_string = caps ? "0123456789ABCDEF" : "0123456789abcdef"; do { - convert[place++] = (caps ? "0123456789ABCDEF" : "0123456789abcdef") - [uvalue % (unsigned)base]; + convert[place++] = cvt_string[uvalue % (unsigned)base]; uvalue = (uvalue / (unsigned)base); - } while (uvalue && (place < 20)); - if (place == 20) { + } while (uvalue && (place < (int)sizeof(convert))); + if (place == (int)sizeof(convert)) { place--; } convert[place] = 0; diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 45001b9574..a47573a231 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,10 @@ Technical notes on version 2.2 General: +23Dec07 +kes Attempt to eliminate seg fault Frank Sweetser is seeing in + running the regression tests on his Fedora systems. It seems + to be related to bsnprintf and long path names. 14Dec07 kes Apply patch from Michael Stapelberg that implements double quoting include names in conf files,