Validate target name in ALIASED_TARGET property getter

This commit is contained in:
Gregor Jasny 2016-06-26 22:00:00 +02:00
parent c68cf9e4d1
commit 2ca76a6651
2 changed files with 15 additions and 20 deletions

View File

@ -248,15 +248,14 @@ bool cmGetPropertyCommand::HandleTargetMode()
return false;
}
if (this->PropertyName == "ALIASED_TARGET") {
if (this->Makefile->IsAlias(this->Name)) {
if (cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) {
if (cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) {
if (this->PropertyName == "ALIASED_TARGET") {
if (this->Makefile->IsAlias(this->Name)) {
return this->StoreResult(target->GetName().c_str());
} else {
return this->StoreResult((this->Variable + "-NOTFOUND").c_str());
}
}
return this->StoreResult((this->Variable + "-NOTFOUND").c_str());
}
if (cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) {
return this->StoreResult(
target->GetProperty(this->PropertyName, this->Makefile));
} else {

View File

@ -24,22 +24,18 @@ bool cmGetTargetPropertyCommand::InitialPass(
std::string prop;
bool prop_exists = false;
if (args[2] == "ALIASED_TARGET") {
if (this->Makefile->IsAlias(targetName)) {
if (cmTarget* target = this->Makefile->FindTargetToUse(targetName)) {
prop = target->GetName();
if (cmTarget* tgt = this->Makefile->FindTargetToUse(targetName)) {
if (args[2] == "ALIASED_TARGET") {
if (this->Makefile->IsAlias(targetName)) {
prop = tgt->GetName();
prop_exists = true;
}
} else if (!args[2].empty()) {
const char* prop_cstr = tgt->GetProperty(args[2], this->Makefile);
if (prop_cstr) {
prop = prop_cstr;
prop_exists = true;
}
}
} else if (cmTarget* tgt = this->Makefile->FindTargetToUse(targetName)) {
cmTarget& target = *tgt;
const char* prop_cstr = 0;
if (!args[2].empty()) {
prop_cstr = target.GetProperty(args[2], this->Makefile);
}
if (prop_cstr) {
prop = prop_cstr;
prop_exists = true;
}
} else {
bool issueMessage = false;