]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/parse_conf.c
- Fix seg fault if user labels a drive directory bug #513
[bacula/bacula] / bacula / src / lib / parse_conf.c
index 2747dd702653f2273c814b320398e4667e666de7..41307bd07b5d9ecca4cea74468e612154dfb09ca 100755 (executable)
@@ -37,7 +37,7 @@
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
-   version 2 as ammended with additional clauses defined in the
+   version 2 as amended with additional clauses defined in the
    file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
@@ -423,7 +423,7 @@ void store_password(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    unsigned int i, j;
    struct MD5Context md5c;
-   unsigned char signature[16];
+   unsigned char digest[CRYPTO_DIGEST_MD5_SIZE];
    char sig[100];
 
 
@@ -431,9 +431,9 @@ void store_password(LEX *lc, RES_ITEM *item, int index, int pass)
    if (pass == 1) {
       MD5Init(&md5c);
       MD5Update(&md5c, (unsigned char *) (lc->str), lc->str_len);
-      MD5Final(signature, &md5c);
-      for (i = j = 0; i < sizeof(signature); i++) {
-         sprintf(&sig[j], "%02x", signature[i]);
+      MD5Final(digest, &md5c);
+      for (i = j = 0; i < sizeof(digest); i++) {
+         sprintf(&sig[j], "%02x", digest[i]);
          j += 2;
       }
       *(item->value) = bstrdup(sig);
@@ -619,9 +619,10 @@ void store_size(LEX *lc, RES_ITEM *item, int index, int pass)
    case T_UNQUOTED_STRING:
       bstrncpy(bsize, lc->str, sizeof(bsize));  /* save first part */
       /* if terminated by space, scan and get modifier */
-      if (lc->ch == ' ') {
+      while (lc->ch == ' ') {
          token = lex_get_token(lc, T_ALL);
          switch (token) {
+         case T_NUMBER:
          case T_IDENTIFIER:
          case T_UNQUOTED_STRING:
             bstrncat(bsize, lc->str, sizeof(bsize));
@@ -660,9 +661,10 @@ void store_time(LEX *lc, RES_ITEM *item, int index, int pass)
    case T_UNQUOTED_STRING:
       bstrncpy(period, lc->str, sizeof(period));  /* get first part */
       /* if terminated by space, scan and get modifier */
-      if (lc->ch == ' ') {
+      while (lc->ch == ' ') {
          token = lex_get_token(lc, T_ALL);
          switch (token) {
+         case T_NUMBER:
          case T_IDENTIFIER:
          case T_UNQUOTED_STRING:
             bstrncat(period, lc->str, sizeof(period));
@@ -694,7 +696,7 @@ void store_yesno(LEX *lc, RES_ITEM *item, int index, int pass)
    } else if (strcasecmp(lc->str, "no") == 0) {
       *(int *)(item->value) &= ~(item->code);
    } else {
-      scan_err1(lc, _("Expect a YES or NO, got: %s"), lc->str);
+      scan_err3(lc, _("Expect a %s or %s, got: %s"), "YES", "NO", lc->str); /* YES and NO must not be translated */
    }
    scan_to_eol(lc);
    set_bit(index, res_all.hdr.item_present);
@@ -718,7 +720,7 @@ void store_label(LEX *lc, RES_ITEM *item, int index, int pass)
       }
    }
    if (i != 0) {
-      scan_err1(lc, "Expected a Tape Label keyword, got: %s", lc->str);
+      scan_err1(lc, _("Expected a Tape Label keyword, got: %s"), lc->str);
    }
    scan_to_eol(lc);
    set_bit(index, res_all.hdr.item_present);