Commit 1f10bc2e authored by Alejandro Alvarez Ayllon's avatar Alejandro Alvarez Ayllon
Browse files

Fix segfault due to *_client_setVOMS_data not making copy

parent 53c930b6
......@@ -255,14 +255,7 @@ void DpmAdapterCatalog::setUserId(uid_t uid, gid_t gid, const std::string& dn) t
void DpmAdapterCatalog::setVomsData(const std::string& vo, const std::vector<std::string>& fqans) throw (DmException)
{
NsAdapterCatalog::setVomsData(vo, fqans);
int nFqans = fqans.size();
char *fqansp[nFqans];
for (int i = 0; i < nFqans; ++i)
fqansp[i] = (char*)fqans[i].c_str();
RETRY(dpm_client_setVOMS_data((char*)vo.c_str(), (char**)fqansp, nFqans),
RETRY(dpm_client_setVOMS_data((char*)this->vo_, this->fqans_, this->nFqans_),
this->retryLimit_);
}
......
......@@ -35,13 +35,24 @@ NsAdapterCatalog::NsAdapterCatalog(const std::string& nsHost, unsigned retryLimi
setenv("DPNS_HOST", this->nsHost_.c_str(), 1);
setenv("CSEC_MECH", "ID", 1);
// These need to be set to 0
this->fqans_ = 0x00;
this->nFqans_ = 0;
this->vo_ = 0x00;
}
NsAdapterCatalog::~NsAdapterCatalog()
{
// Nothing
if (this->fqans_ != 0x00) {
for (int i = 0; i < this->nFqans_; ++i)
delete [] this->fqans_[i];
delete [] this->fqans_;
}
if (this->vo_ != 0x00)
delete [] this->vo_;
}
......@@ -463,7 +474,8 @@ void NsAdapterCatalog::removeDir(const std::string& path) throw (DmException)
void NsAdapterCatalog::setUserId(uid_t uid, gid_t gid, const std::string& dn) throw (DmException)
{
wrapCall(dpns_client_setAuthorizationId(uid, gid, "GSI", (char*)dn.c_str()));
wrapCall(dpns_client_setAuthorizationId(uid, gid, "GSI",
(char*)dn.c_str()));
}
......@@ -471,13 +483,32 @@ void NsAdapterCatalog::setUserId(uid_t uid, gid_t gid, const std::string& dn) th
void NsAdapterCatalog::setVomsData(const std::string& vo,
const std::vector<std::string>& fqans) throw (DmException)
{
int nFqans = fqans.size();
char *fqansp[nFqans];
for (int i = 0; i < nFqans; ++i)
fqansp[i] = (char*)fqans[i].c_str();
// Free any remaning
if (this->fqans_ != 0x00) {
for (int i = 0; i < this->nFqans_; ++i)
delete [] this->fqans_[i];
delete [] this->fqans_;
}
if (this->vo_ != 0x00)
delete [] this->vo_;
wrapCall(dpns_client_setVOMS_data((char*)vo.c_str(), fqansp, nFqans));
// Copy VO
this->vo_ = new char[vo.length() + 1];
strcpy(this->vo_, vo.c_str());
// Allocate memory for the array
this->nFqans_ = fqans.size();
this->fqans_ = new char*[this->nFqans_];
// Copy the fqans
for (int i = 0; i < this->nFqans_; ++i) {
this->fqans_[i] = new char [fqans[i].length() + 1];
strcpy(this->fqans_[i], fqans[i].c_str());
}
// Pass the data
wrapCall(dpns_client_setVOMS_data((char*)this->vo_,
this->fqans_, this->nFqans_));
}
......
......@@ -96,6 +96,13 @@ protected:
unsigned retryLimit_;
std::string cwdPath_;
// Need to keep this in memory, as dpns/dpm API do not make
// copy of them (sigh)
// setAuthorizationId does, though (don't ask me why)
char **fqans_;
int nFqans_;
char *vo_;
private:
std::string nsHost_;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment