From be49d14df3610d991722f28148221e75ae3f91ef Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Tue, 14 Oct 2008 15:53:03 +0000 Subject: [PATCH] ebl Fix bug with ansi label when volume name length < 6 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7787 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/ansi_label.c | 14 ++++++++++++-- bacula/technotes-2.5 | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bacula/src/stored/ansi_label.c b/bacula/src/stored/ansi_label.c index a6bacf547c..6a8fa41829 100644 --- a/bacula/src/stored/ansi_label.c +++ b/bacula/src/stored/ansi_label.c @@ -278,6 +278,7 @@ bool write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName) { DEVICE *dev = dcr->dev; JCR *jcr = dcr->jcr; + char ansi_volname[7]; /* 6 char + \0 */ char label[80]; /* tape label */ char date[20]; /* ansi date buffer */ time_t now; @@ -306,10 +307,19 @@ bool write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName) VolName); return false; } + /* ANSI labels have 6 characters, and are padded with spaces + * 'vol1\0' => 'vol1 \0' + */ + strcpy(ansi_volname, VolName); + for(int i=len; i < 6; i++) { + ansi_volname[i]=' '; + } + ansi_volname[6]='\0'; /* only for debug */ + if (type == ANSI_VOL_LABEL) { ser_begin(label, sizeof(label)); ser_bytes("VOL1", 4); - ser_bytes(VolName, len); + ser_bytes(ansi_volname, 6); /* Write VOL1 label */ if (label_type == B_IBM_LABEL) { ascii_to_ebcdic(label, label, sizeof(label)); @@ -332,7 +342,7 @@ bool write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName) ser_bytes("1", 1); ser_bytes("BACULA.DATA", 11); /* Filename field */ ser_begin(&label[21], sizeof(label)-21); /* fileset field */ - ser_bytes(VolName, len); /* write Vol Ser No. */ + ser_bytes(ansi_volname, 6); /* write Vol Ser No. */ ser_begin(&label[27], sizeof(label)-27); ser_bytes("00010001000100", 14); /* File section, File seq no, Generation no */ now = time(NULL); diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 3afdf29ddf..4be9091ca9 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -18,6 +18,7 @@ remove reader/writer in FOPTS???? General: 14Oct08 +ebl Fix bug with ansi label when volume name length < 6 ebl Fix segfault in debug level > 50 with btape. ebl Remove warning message in btape when command is empty. kes Fix Win32 build to pull in new BACULA define. -- 2.39.2