From: Eric Bollengier Date: Tue, 14 Oct 2008 15:53:03 +0000 (+0000) Subject: ebl Fix bug with ansi label when volume name length < 6 X-Git-Tag: Release-7.0.0~3960 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=54e2dea7d2cd00059cc64aaa0a2a0789862c0cb1;p=bacula%2Fbacula 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 --- 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.