Patched crash bug caused by changed semantics of Socket copy

git-svn-id: svn://ultimatepp.org/upp/trunk@952 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
rylek 2009-03-12 23:34:58 +00:00
parent d3430589f2
commit d5101ea69b
2 changed files with 3520 additions and 41 deletions

File diff suppressed because it is too large Load diff

View file

@ -97,7 +97,7 @@ protected:
class CommandConnection : public Connection
{
public:
CommandConnection(Socket socket, const char *command);
CommandConnection(Socket& socket, const char *command);
virtual bool Run();
@ -126,50 +126,59 @@ CommandServer::Connection::~Connection()
//////////////////////////////////////////////////////////////////////
// CommandServer::CommandConnection::
CommandServer::CommandConnection::CommandConnection(Socket _socket, const char *_command)
CommandServer::CommandConnection::CommandConnection(Socket& _socket, const char *_command)
: Connection(_socket)
{
String environment;
String pathlist;
if(*_command == ':') {
const char *b = ++_command;
while(*_command && *_command++ != '\n')
;
environment = ASCII85Decode(String(b, _command));
for(b = environment; *b; b += strlen(b) + 1)
if(!MemICmp(b, "PATH=", 5)) {
pathlist = b + 5;
break;
}
}
if(*_command == '=')
_command++;
String command = _command;
if(!IsNull(pathlist)) {
String exec;
if(*_command == '\"') {
while(*++_command && (*_command != '\"' || *++_command == '\"'))
exec.Cat(*_command);
_socket.Clear();
try {
String environment;
String pathlist;
if(*_command == ':') {
const char *b = ++_command;
while(*_command && *_command++ != '\n')
;
environment = ASCII85Decode(String(b, _command));
for(b = environment; *b; b += strlen(b) + 1)
if(!MemICmp(b, "PATH=", 5)) {
pathlist = b + 5;
break;
}
}
else
while(*_command && (byte)*_command > ' ')
exec.Cat(*_command++);
command = GetFileOnPath(exec, pathlist, true);
#ifdef PLATFORM_WIN32
if(IsNull(command))
command = GetFileOnPath(exec + ".exe", pathlist, true);
#endif
if(IsNull(command))
command = exec;
if(command.Find(' ') >= 0)
command = '\"' + command + '\"';
command << ' ' << _command;
if(*_command == '=')
_command++;
String command = _command;
if(!IsNull(pathlist)) {
String exec;
if(*_command == '\"') {
while(*++_command && (*_command != '\"' || *++_command == '\"'))
exec.Cat(*_command);
}
else
while(*_command && (byte)*_command > ' ')
exec.Cat(*_command++);
command = GetFileOnPath(exec, pathlist, true);
#ifdef PLATFORM_WIN32
if(IsNull(command))
command = GetFileOnPath(exec + ".exe", pathlist, true);
#endif
if(IsNull(command))
command = exec;
if(command.Find(' ') >= 0)
command = '\"' + command + '\"';
command << ' ' << _command;
}
LOG("CommandServer::CommandConnection(" << command << ")");
slave = StartProcess(command, environment);
LOG("CommandServer::CommandConnection -> OK");
socket.Write("+\0", 2);
name << "[command]" << command;
}
catch(Exc e) {
if(socket.IsOpen())
socket.Write('-' + e + '\0');
throw;
}
LOG("CommandServer::CommandConnection(" << command << ")");
slave = StartProcess(command, environment);
LOG("CommandServer::CommandConnection -> OK");
socket.Write("+\0", 2);
name << "[command]" << command;
}
bool CommandServer::CommandConnection::Run()