Commit 79a8f8f9 authored by sletz's avatar sletz
Browse files

Correct PortRegister, port name checking must be done on server side.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2095 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 513520c9
......@@ -20,6 +20,10 @@ Fernando Lopez-Lezcano
Jackdmp changes log
---------------------------
2008-03-28 Stephane Letz <letz@grame.fr>
* Correct PortRegister, port name checking must be done on server side.
2008-03-27 Stephane Letz <letz@grame.fr>
* Pieter Palmers patch for FFADO driver.
......
......@@ -479,37 +479,30 @@ inline int JackClient::Error()
int JackClient::PortRegister(const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size)
{
// Check port name length
// Check if port name is empty
string port_name_str = string(port_name);
if (port_name_str.size() == 0) {
jack_error("port_name is empty.");
jack_error("port_name is empty");
return 0; // Means failure here...
}
// Check port name length
string name = string(GetClientControl()->fName) + string(":") + port_name_str;
if (name.size() >= JACK_PORT_NAME_SIZE) {
jack_error("\"%s:%s\" is too long to be used as a JACK port name.\n"
"Please use %lu characters or less.",
"Please use %lu characters or less",
GetClientControl()->fName,
port_name,
JACK_PORT_NAME_SIZE - 1);
return 0; // Means failure here...
}
// Check if port name already exists
if (GetGraphManager()->GetPort(name.c_str()) != NO_PORT) {
jack_error("port_name \"%s\" already exists.", port_name);
return 0; // Means failure here...
}
jack_log("JackClient::PortRegister ref = %ld name = %s type = %s", GetClientControl()->fRefNum, name.c_str(), port_type);
int result = -1;
unsigned int port_index = NO_PORT;
fChannel->PortRegister(GetClientControl()->fRefNum, name.c_str(), port_type, flags, buffer_size, &port_index, &result);
jack_log("JackClient::PortRegister port_index = %ld ", port_index);
if (result == 0) {
jack_log("JackClient::PortRegister ref = %ld name = %s type = %s port_index = %ld", GetClientControl()->fRefNum, name.c_str(), port_type, port_index);
fPortList.push_back(port_index);
return port_index;
} else {
......
......@@ -641,6 +641,12 @@ int JackEngine::PortRegister(int refnum, const char* name, const char *type, uns
{
jack_log("JackEngine::PortRegister ref = %ld name = %s type = %s flags = %d buffer_size = %d", refnum, name, type, flags, buffer_size);
assert(fClientTable[refnum]);
// Check if port name already exists
if (GetGraphManager()->GetPort(name) != NO_PORT) {
jack_error("port_name \"%s\" already exists", name);
return -1;
}
*port_index = fGraphManager->AllocatePort(refnum, name, type, (JackPortFlags)flags, fEngineControl->fBufferSize);
if (*port_index != NO_PORT) {
......
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