]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix buffer overruns detected by Coverity
authorKern Sibbald <kern@sibbald.com>
Sat, 17 May 2008 23:28:41 +0000 (23:28 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 17 May 2008 23:28:41 +0000 (23:28 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@6983 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/migrate.c
bacula/src/dird/ua_restore.c
bacula/technotes-2.1

index e5fd3fdba4283e7bb538b65a78607bbfe219c231..9c4dc8a314bc537874632675bfdc10e6646d8353 100644 (file)
@@ -404,13 +404,14 @@ struct idpkt {
 /* Add an item to the list if it is unique */
 static void add_unique_id(idpkt *ids, char *item) 
 {
-   char id[30];
+   const int maxlen = 30;
+   char id[maxlen+1];
    char *q = ids->list;
 
    /* Walk through current list to see if each item is the same as item */
    for ( ; *q; ) {
        id[0] = 0;
-       for (int i=0; i<(int)sizeof(id); i++) {
+       for (int i=0; i<maxlen; i++) {
           if (*q == 0) {
              break;
           } else if (*q == ',') {
@@ -1242,11 +1243,12 @@ void migration_cleanup(JCR *jcr, int TermCode)
  */
 static int get_next_dbid_from_list(char **p, DBId_t *DBId)
 {
-   char id[30];
+   const int maxlen = 30;
+   char id[maxlen+1];
    char *q = *p;
 
    id[0] = 0;
-   for (int i=0; i<(int)sizeof(id); i++) {
+   for (int i=0; i<maxlen; i++) {
       if (*q == 0) {
          break;
       } else if (*q == ',') {
index 06287fcd2e3850ebd016c6ee0daf9cc07136b5e9..7d8360a2d7c36b2286d0325fc9287c586b25ad95 100644 (file)
@@ -1267,11 +1267,12 @@ bail_out:
  */
 int get_next_jobid_from_list(char **p, JobId_t *JobId)
 {
-   char jobid[30];
+   const int maxlen = 30;
+   char jobid[maxlen+1];
    char *q = *p;
 
    jobid[0] = 0;
-   for (int i=0; i<(int)sizeof(jobid); i++) {
+   for (int i=0; i<maxlen; i++) {
       if (*q == 0) {
          break;
       } else if (*q == ',') {
@@ -1436,6 +1437,7 @@ void find_storage_resource(UAContext *ua, RESTORE_CTX &rx, char *Storage, char *
 
    /* Take command line arg, or ask user if none */
    rx.store = get_storage_resource(ua, false /* don't use default */);
-   Dmsg1(200, "Set store=%s\n", rx.store->name());
-
+   if (rx.store) {
+      Dmsg1(200, "Set store=%s\n", rx.store->name());
+   }
 }
index 35640631458d962476dac877a81411ae3bd74675..9ec0d0081255bab5bea4a6c4954a05b29dc6864a 100644 (file)
@@ -1,6 +1,8 @@
               Technical notes on version 2.2
 
 General:
+17May08
+kes  Fix buffer overruns detected by Coverity.
 
 Beta Release Version 2.2.10-b3
 13May08