From a76358f340918214c1923126d360210e3db7ef33 Mon Sep 17 00:00:00 2001
From: Steven Murray <murrayc3@cern.ch>
Date: Tue, 7 Aug 2012 09:59:21 +0000
Subject: [PATCH] bug #96536: rmlabelinfo() of tape/initlabel.c corrupts memory
 if called more than once

In order to improve logging for tape-operations and to facilitate the current
testing surrounding this bug, the serrno code of ENOMEM has been replaced by
the more specific error ETNOLBLINFOMEM meaning "No memory available for label
information" within the setlabelinfo function.
---
 mediachanger/castorrmc/common/serror.c | 1 +
 mediachanger/castorrmc/h/serrno.h      | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/mediachanger/castorrmc/common/serror.c b/mediachanger/castorrmc/common/serror.c
index e943863b05..0ae29e5299 100644
--- a/mediachanger/castorrmc/common/serror.c
+++ b/mediachanger/castorrmc/common/serror.c
@@ -341,6 +341,7 @@ char *sys_terrlist[ETMAXERR-ETBASEOFF+2] =
    "castor::tape::net::acceptConnection interrupted",
    "Label information not found in memory",
    "Multi-drive reservations are not supported",
+   "No memory available for label information",
    "BAD ERROR NUMBER"
   };
 
diff --git a/mediachanger/castorrmc/h/serrno.h b/mediachanger/castorrmc/h/serrno.h
index b931428754..90763ecaca 100644
--- a/mediachanger/castorrmc/h/serrno.h
+++ b/mediachanger/castorrmc/h/serrno.h
@@ -345,7 +345,8 @@
 #define ETNETACCEPTINTR ETBASEOFF+34    /* castor::tape::net::acceptConnection interrupted */
 #define ETNOLBLINFO	ETBASEOFF+35    /* Label information not found in memory */
 #define ETMLTDRVRSV	ETBASEOFF+36    /* Multi-drive reservations are not supported */
-#define ETMAXERR        ETBASEOFF+36
+#define ETNOLBLINFOMEM	ETBASEOFF+37    /* No memory available for label information */
+#define ETMAXERR        ETBASEOFF+37
 
 /*
  *------------------------------------------------------------------------
-- 
GitLab