- Add support for commands that want to read before they write anything.

- A couple of changes to avoid false error messages in valgrind.
- Fixed a bug that could potentially lead to a double-free()


git-svn-id: https://shellinabox.googlecode.com/svn/trunk@114 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
zodiac 2009-04-16 05:33:05 +00:00
parent f8c85ae26f
commit 0258d46926
5 changed files with 15 additions and 13 deletions

View file

@ -2,7 +2,7 @@ AC_PREREQ(2.57)
dnl This is the one location where the authoritative version number is stored dnl This is the one location where the authoritative version number is stored
AC_INIT(shellinabox, 2.6, markus@shellinabox.com) AC_INIT(shellinabox, 2.6, markus@shellinabox.com)
VCS_REVISION=113 VCS_REVISION=114
AC_SUBST(VCS_REVISION) AC_SUBST(VCS_REVISION)
AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}", AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
[Most recent revision number in the version control system]) [Most recent revision number in the version control system])

View file

@ -354,6 +354,7 @@ void destroyHttpConnection(struct HttpConnection *http) {
if (http->callback && !http->done) { if (http->callback && !http->done) {
http->callback(http, http->arg, NULL, 0); http->callback(http, http->arg, NULL, 0);
} }
http->callback = NULL;
http->isSuspended = 0; http->isSuspended = 0;
http->isPartialReply = 0; http->isPartialReply = 0;
} }

View file

@ -383,16 +383,16 @@ void serverLoop(struct Server *server) {
// the end of the list. // the end of the list.
check(--numFds > 0); check(--numFds > 0);
struct pollfd tmpPollFd; struct pollfd tmpPollFd;
memcpy(&tmpPollFd, server->pollFds + numFds, sizeof(struct pollfd)); memmove(&tmpPollFd, server->pollFds + numFds, sizeof(struct pollfd));
memcpy(server->pollFds + numFds, server->pollFds + i + 1, memmove(server->pollFds + numFds, server->pollFds + i + 1,
sizeof(struct pollfd)); sizeof(struct pollfd));
memcpy(server->pollFds + i + 1, &tmpPollFd, sizeof(struct pollfd)); memmove(server->pollFds + i + 1, &tmpPollFd, sizeof(struct pollfd));
struct ServerConnection tmpConnection; struct ServerConnection tmpConnection;
memcpy(&tmpConnection, server->connections + numFds - 1, memmove(&tmpConnection, server->connections + numFds - 1,
sizeof(struct ServerConnection)); sizeof(struct ServerConnection));
memcpy(server->connections + numFds - 1, server->connections + i, memmove(server->connections + numFds - 1, server->connections + i,
sizeof(struct ServerConnection)); sizeof(struct ServerConnection));
memcpy(server->connections + i, &tmpConnection, memmove(server->connections + i, &tmpConnection,
sizeof(struct ServerConnection)); sizeof(struct ServerConnection));
} }

View file

@ -1255,7 +1255,7 @@ static void launcherDaemon(int fd) {
} }
// Send file handle and process id back to parent // Send file handle and process id back to parent
char cmsg_buf[CMSG_SPACE(sizeof(int))]; char cmsg_buf[CMSG_SPACE(sizeof(int))] = { 0 };
struct iovec iov = { 0 }; struct iovec iov = { 0 };
struct msghdr msg = { 0 }; struct msghdr msg = { 0 };
iov.iov_base = &pid; iov.iov_base = &pid;

View file

@ -397,6 +397,7 @@ static int dataHandler(HttpConnection *http, struct Service *service,
} }
free(keyCodes); free(keyCodes);
httpSendReply(http, 200, "OK", " "); httpSendReply(http, 200, "OK", " ");
check(session->http != http);
return HTTP_DONE; return HTTP_DONE;
} else { } else {
// This request is polling for data. Finish any pending requests and // This request is polling for data. Finish any pending requests and
@ -412,7 +413,7 @@ static int dataHandler(HttpConnection *http, struct Service *service,
session->connection = serverGetConnection(session->server, session->connection = serverGetConnection(session->server,
session->connection, session->connection,
session->pty); session->pty);
if (session->buffered) { if (session->buffered || isNew) {
if (completePendingRequest(session, "", 0, MAX_RESPONSE) && if (completePendingRequest(session, "", 0, MAX_RESPONSE) &&
session->connection) { session->connection) {
// Reset the timeout, as we just received a new request. // Reset the timeout, as we just received a new request.