]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix possible buffer overrun in restore tree routine
authorKern Sibbald <kern@sibbald.com>
Mon, 23 Jun 2003 19:21:42 +0000 (19:21 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 23 Jun 2003 19:21:42 +0000 (19:21 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@608 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/ua_tree.c
bacula/src/stored/askdir.c
bacula/src/stored/autochanger.c
bacula/src/stored/dev.h

index a3ae58683c80292fe12ed9b48eaed4f0b20fb579..8b855085f8213129b2b94626f9d42d028566cabf 100644 (file)
@@ -126,7 +126,7 @@ void user_select_files_from_tree(TREE_CTX *tree)
 int insert_tree_handler(void *ctx, int num_fields, char **row)
 {
    TREE_CTX *tree = (TREE_CTX *)ctx;
-   char fname[2000];
+   char fname[5000];
    TREE_NODE *node, *new_node;
    int type;
 
@@ -140,7 +140,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row)
    } else {
       type = TN_FILE;
    }
-   sprintf(fname, "%s%s", row[0], row[1]);
+   bsnprintf(fname, sizeof(fname), "%s%s", row[0]?row[0]:"", row[1]?row[1]:"");
    if (tree->avail_node) {
       node = tree->avail_node;
    } else {
index bad70ce0af27e13e4956c1d9e40ae0067de15a6a..ac8f9284414330bfd9b85ee8ce411e13c6a434fb 100644 (file)
@@ -321,7 +321,7 @@ Please use the \"label\"  command to create a new Volume for:\n\
             Mmsg(&dev->errmsg, _("Gave up waiting to mount Storage Device \"%s\" for Job %s\n"), 
                 jcr->dev_name, jcr->Job);
             Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
-            Dmsg1(190, "Gave up waiting on device %s\n", dev->dev_name);
+            Dmsg1(190, "Gave up waiting on device %s\n", dev_name(dev));
            return 0;                 /* exceeded maximum waits */
         }
         continue;
@@ -336,7 +336,7 @@ Please use the \"label\"  command to create a new Volume for:\n\
          Jmsg(jcr, M_WARNING, 0, _("pthread error in mount_next_volume stat=%d ERR=%s\n"), stat,
            strerror(stat));
       }
-      Dmsg1(190, "Someone woke me for device %s\n", dev->dev_name);
+      Dmsg1(190, "Someone woke me for device %s\n", dev_name(dev));
 
       /* Restart wait counters */
       wait_sec = min_wait;
@@ -413,7 +413,7 @@ int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev)
             Mmsg(&dev->errmsg, _("Gave up waiting to mount Storage Device \"%s\" for Job %s\n"), 
                 jcr->dev_name, jcr->Job);
             Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
-            Dmsg1(190, "Gave up waiting on device %s\n", dev->dev_name);
+            Dmsg1(190, "Gave up waiting on device %s\n", dev_name(dev));
            return 0;                 /* exceeded maximum waits */
         }
         continue;
@@ -428,7 +428,7 @@ int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev)
          Jmsg(jcr, M_ERROR, 0, _("pthread error in mount_next_volume stat=%d ERR=%s\n"), stat,
            strerror(stat));
       }
-      Dmsg1(190, "Someone woke me for device %s\n", dev->dev_name);
+      Dmsg1(190, "Someone woke me for device %s\n", dev_name(dev));
 
       /* Restart wait counters */
       wait_sec = min_wait;
@@ -476,7 +476,7 @@ static int wait_for_sysop(JCR *jcr, DEVICE *dev, int wait_sec)
    for ( ; !job_canceled(jcr); ) {
       time_t now;
 
-      Dmsg3(100, "I'm going to sleep on device %s. HB=%d wait=%d\n", dev->dev_name,
+      Dmsg3(100, "I'm going to sleep on device %s. HB=%d wait=%d\n", dev_name(dev),
         (int)me->heartbeat_interval, wait_sec);
       stat = pthread_cond_timedwait(&dev->wait_next_vol, &dev->mutex, &timeout);
       Dmsg1(100, "Wokeup from sleep on device stat=%d\n", stat);
index 46922205b2be95c29308f99a9b2a3a03b12f0a5a..a6a19870c99d6ffdf73302358d91e91f6a7caa7c 100644 (file)
@@ -222,7 +222,7 @@ static char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd)
             str = "%";
            break;
          case 'a':
-           str = jcr->device->dev->dev_name;
+           str = dev_name(jcr->device->dev);
            break;
          case 'c':
            str = NPRT(jcr->device->changer_name);
index 9f8eeb2c38cf81ac65da7ff48df05471fd05674f..70e7b9b8f1138a2afcc9ad9b04a394f95f35fc4c 100644 (file)
@@ -143,9 +143,10 @@ struct DEVRES;                        /* Device resource defined in stored_conf.
 
 /* Device structure definition */
 struct DEVICE {
+public:
    DEVICE *next;                      /* pointer to next open device */
    DEVICE *prev;                      /* pointer to prev open device */
-   JCR *attached_jcrs;              /* attached JCR list */
+   JCR *attached_jcrs;                /* attached JCR list */
    pthread_mutex_t mutex;             /* access control */
    pthread_cond_t wait;               /* thread wait variable */
    pthread_cond_t wait_next_vol;      /* wait for tape to be mounted */
@@ -179,7 +180,7 @@ struct DEVICE {
 
    VOLUME_CAT_INFO VolCatInfo;        /* Volume Catalog Information */
    VOLUME_LABEL VolHdr;               /* Actual volume label */
-
+   
 };