mirror of
https://github.com/clearml/dropbear
synced 2025-02-07 13:21:15 +00:00
Prevent multiple shells being spawned
Existing shells would be leaked. The old check only caught multiple commands, not shells.
This commit is contained in:
parent
6c571c54e5
commit
67a8de30b7
@ -658,12 +658,13 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,
|
|||||||
unsigned int cmdlen = 0;
|
unsigned int cmdlen = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
TRACE(("enter sessioncommand"))
|
TRACE(("enter sessioncommand %d", channel->index))
|
||||||
|
|
||||||
if (chansess->cmd != NULL) {
|
if (chansess->pid != 0) {
|
||||||
/* Note that only one command can _succeed_. The client might try
|
/* Note that only one command can _succeed_. The client might try
|
||||||
* one command (which fails), then try another. Ie fallback
|
* one command (which fails), then try another. Ie fallback
|
||||||
* from sftp to scp */
|
* from sftp to scp */
|
||||||
|
TRACE(("leave sessioncommand, already have a command"))
|
||||||
return DROPBEAR_FAILURE;
|
return DROPBEAR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,6 +676,7 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,
|
|||||||
if (cmdlen > MAX_CMD_LEN) {
|
if (cmdlen > MAX_CMD_LEN) {
|
||||||
m_free(chansess->cmd);
|
m_free(chansess->cmd);
|
||||||
/* TODO - send error - too long ? */
|
/* TODO - send error - too long ? */
|
||||||
|
TRACE(("leave sessioncommand, command too long %d", cmdlen))
|
||||||
return DROPBEAR_FAILURE;
|
return DROPBEAR_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -687,6 +689,7 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
m_free(chansess->cmd);
|
m_free(chansess->cmd);
|
||||||
|
TRACE(("leave sessioncommand, unknown subsystem"))
|
||||||
return DROPBEAR_FAILURE;
|
return DROPBEAR_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -743,6 +746,7 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,
|
|||||||
if (ret == DROPBEAR_FAILURE) {
|
if (ret == DROPBEAR_FAILURE) {
|
||||||
m_free(chansess->cmd);
|
m_free(chansess->cmd);
|
||||||
}
|
}
|
||||||
|
TRACE(("leave sessioncommand, ret %d", ret))
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -916,6 +920,7 @@ static void addchildpid(struct ChanSess *chansess, pid_t pid) {
|
|||||||
svr_ses.childpidsize++;
|
svr_ses.childpidsize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACE(("addchildpid %d pid %d for chansess %p", i, pid, chansess))
|
||||||
svr_ses.childpids[i].pid = pid;
|
svr_ses.childpids[i].pid = pid;
|
||||||
svr_ses.childpids[i].chansess = chansess;
|
svr_ses.childpids[i].chansess = chansess;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user