From 2b60e70664f349c3156393965a418b0d40f53d51 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 18 Mar 2004 17:25:01 +0000 Subject: [PATCH] Fix sql path length=0 bug git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1140 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/cats/sql_get.c | 4 +- bacula/src/lib/scan.c | 106 +++++++++++++++++++------------------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index a1abcbd323..2f1c7bbe36 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -322,8 +322,8 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum db_lock(mdb); Mmsg(&mdb->cmd, "SELECT DISTINCT VolumeName FROM JobMedia,Media WHERE " - "JobMedia.JobId=%u AND JobMedia.MediaId=Media.MediaId", - JobId); + "JobMedia.JobId=%u AND JobMedia.MediaId=Media.MediaId " + "ORDER BY VolIndex", JobId); Dmsg1(130, "VolNam=%s\n", mdb->cmd); *VolumeNames[0] = 0; diff --git a/bacula/src/lib/scan.c b/bacula/src/lib/scan.c index ac1447a721..0289b85d09 100644 --- a/bacula/src/lib/scan.c +++ b/bacula/src/lib/scan.c @@ -1,7 +1,7 @@ /* * scan.c -- scanning routines for Bacula * - * Kern Sibbald, MM separated from util.c MMIII + * Kern Sibbald, MM separated from util.c MMIII * * Version $Id$ */ @@ -55,9 +55,9 @@ void strip_trailing_slashes(char *dir) /* * Skip spaces - * Returns: 0 on failure (EOF) - * 1 on success - * new address in passed parameter + * Returns: 0 on failure (EOF) + * 1 on success + * new address in passed parameter */ bool skip_spaces(char **msg) { @@ -74,9 +74,9 @@ bool skip_spaces(char **msg) /* * Skip nonspaces - * Returns: 0 on failure (EOF) - * 1 on success - * new address in passed parameter + * Returns: 0 on failure (EOF) + * 1 on success + * new address in passed parameter */ bool skip_nonspaces(char **msg) { @@ -101,19 +101,19 @@ fstrsch(char *a, char *b) /* folded case search */ s1=a; s2=b; - while (*s1) { /* do it the fast way */ + while (*s1) { /* do it the fast way */ if ((*s1++ | 0x20) != (*s2++ | 0x20)) - return 0; /* failed */ + return 0; /* failed */ } - while (*a) { /* do it over the correct slow way */ + while (*a) { /* do it over the correct slow way */ if (B_ISUPPER(c1 = *a)) { - c1 = tolower((int)c1); + c1 = tolower((int)c1); } if (B_ISUPPER(c2 = *b)) { - c2 = tolower((int)c2); + c2 = tolower((int)c2); } if (c1 != c2) { - return 0; + return 0; } a++; b++; @@ -134,31 +134,31 @@ char *next_arg(char **s) /* skip past spaces to next arg */ for (p=*s; *p && B_ISSPACE(*p); ) { p++; - } + } Dmsg1(400, "Next arg=%s\n", p); for (n = q = p; *p ; ) { if (*p == '\\') { - p++; - if (*p) { - *q++ = *p++; - } else { - *q++ = *p; - } - continue; + p++; + if (*p) { + *q++ = *p++; + } else { + *q++ = *p; + } + continue; } if (*p == '"') { /* start or end of quote */ - if (in_quote) { - p++; /* skip quote */ - in_quote = false; - continue; - } - in_quote = true; - p++; - continue; + if (in_quote) { + p++; /* skip quote */ + in_quote = false; + continue; + } + in_quote = true; + p++; + continue; } if (!in_quote && B_ISSPACE(*p)) { /* end of field */ - p++; - break; + p++; + break; } *q++ = *p++; } @@ -189,7 +189,7 @@ char *next_arg(char **s) */ int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, - char **argk, char **argv, int max_args) + char **argk, char **argv, int max_args) { char *p, *q, *n; @@ -201,33 +201,33 @@ int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, while (*argc < max_args) { n = next_arg(&p); if (*n) { - argk[*argc] = n; - argv[(*argc)++] = NULL; + argk[*argc] = n; + argv[(*argc)++] = NULL; } else { - break; + break; } } /* Separate keyword and value */ for (int i=0; i < *argc; i++) { p = strchr(argk[i], '='); if (p) { - *p++ = 0; /* terminate keyword and point to value */ - /* Unquote quoted values */ + *p++ = 0; /* terminate keyword and point to value */ + /* Unquote quoted values */ if (*p == '"') { for (n = q = ++p; *p && *p != '"'; ) { if (*p == '\\') { - p++; - } - *q++ = *p++; - } - *q = 0; /* terminate string */ - p = n; /* point to string */ - } - if (strlen(p) > MAX_NAME_LENGTH-1) { - p[MAX_NAME_LENGTH-1] = 0; /* truncate to max len */ - } + p++; + } + *q++ = *p++; + } + *q = 0; /* terminate string */ + p = n; /* point to string */ + } + if (strlen(p) > MAX_NAME_LENGTH-1) { + p[MAX_NAME_LENGTH-1] = 0; /* truncate to max len */ + } } - argv[i] = p; /* save ptr to value or NULL */ + argv[i] = p; /* save ptr to value or NULL */ } #ifdef xxxx for (int i=0; i < *argc; i++) { @@ -243,7 +243,7 @@ int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, * in the arguments provided. */ void split_path_and_filename(const char *fname, POOLMEM **path, int *pnl, - POOLMEM **file, int *fnl) + POOLMEM **file, int *fnl) { const char *p, *f; int slen; @@ -259,7 +259,7 @@ void split_path_and_filename(const char *fname, POOLMEM **path, int *pnl, p = fname; f = fname + len - 1; /* "strip" any trailing slashes */ - while (slen > 0 && *f == '/') { + while (slen > 1 && *f == '/') { slen--; f--; } @@ -269,15 +269,15 @@ void split_path_and_filename(const char *fname, POOLMEM **path, int *pnl, f--; } if (*f == '/') { /* did we find a slash? */ - f++; /* yes, point to filename */ - } else { /* no, whole thing must be path name */ + f++; /* yes, point to filename */ + } else { /* no, whole thing must be path name */ f = fname; } Dmsg2(200, "after strip len=%d f=%s\n", len, f); *fnl = fname - f + len; if (*fnl > 0) { *file = check_pool_memory_size(*file, *fnl+1); - memcpy(*file, f, *fnl); /* copy filename */ + memcpy(*file, f, *fnl); /* copy filename */ } (*file)[*fnl] = 0; -- 2.39.2