diff options
| author | Franklin Wei <git@fwei.tk> | 2016-01-23 15:25:34 -0500 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2016-01-23 15:25:34 -0500 |
| commit | 636634f244bbe04c703b5019f26578ac5441fefd (patch) | |
| tree | 488a725b47f8bcc925f78b59665231742cf80a41 /src | |
| parent | bb90172cbaa3a38f58293982a38f6854d9afe1f9 (diff) | |
| download | netcosm-636634f244bbe04c703b5019f26578ac5441fefd.zip netcosm-636634f244bbe04c703b5019f26578ac5441fefd.tar.gz netcosm-636634f244bbe04c703b5019f26578ac5441fefd.tar.bz2 netcosm-636634f244bbe04c703b5019f26578ac5441fefd.tar.xz | |
stuff
Diffstat (limited to 'src')
| -rw-r--r-- | src/client.c | 4 | ||||
| -rw-r--r-- | src/globals.h | 1 | ||||
| -rw-r--r-- | src/room.c | 4 | ||||
| -rw-r--r-- | src/telnet.c | 6 |
4 files changed, 9 insertions, 6 deletions
diff --git a/src/client.c b/src/client.c index 91cbbac..cbfe63b 100644 --- a/src/client.c +++ b/src/client.c @@ -155,6 +155,7 @@ void send_master(unsigned char cmd, const void *data, size_t sz) if(data) memcpy(req + sizeof(pid_t) + 1, data, sz); + assert(1 + sizeof(pid_t) + sz <= MSG_MAX); write(to_parent, req, 1 + sizeof(pid_t) + sz); /* poll till we get data */ @@ -279,8 +280,6 @@ bool poll_requests(void) unsigned char cmd = packet[0]; - debugf("Child gets code %d\n", cmd); - switch(cmd) { case REQ_BCASTMSG: @@ -658,6 +657,7 @@ auth: //} } + /* unprivileged commands */ if(!strcmp(tok, "QUIT") || !strcmp(tok, "EXIT")) { free(cmd); diff --git a/src/globals.h b/src/globals.h index 9fb2e5d..1daac8e 100644 --- a/src/globals.h +++ b/src/globals.h @@ -26,6 +26,7 @@ #include <openssl/opensslv.h> #include <arpa/inet.h> +#include <arpa/telnet.h> #include <assert.h> #include <ctype.h> #include <errno.h> @@ -175,7 +175,7 @@ bool world_load(const char *fname, const struct roomdata_t *data, size_t data_sz for(unsigned i = 0; i < world_sz; ++i) { - world[i].users = hash_init((userdb_size() + 1) / 2, pid_hash, pid_equal); + world[i].users = hash_init((userdb_size() / 2) + 1, pid_hash, pid_equal); world[i].id = read_roomid(fd); memcpy(&world[i].data, data + i, sizeof(struct roomdata_t)); @@ -227,7 +227,7 @@ void world_init(const struct roomdata_t *data, size_t sz, const char *name) } } - world[i].users = hash_init((userdb_size() + 1) / 2, pid_hash, pid_equal); + world[i].users = hash_init((userdb_size() / 2) + 1, pid_hash, pid_equal); world_sz = i + 1; } diff --git a/src/telnet.c b/src/telnet.c index a4efac4..a28752a 100644 --- a/src/telnet.c +++ b/src/telnet.c @@ -16,11 +16,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#define TELCMDS +#define TELOPTS #include "globals.h" #include "client.h" - -#define TELCMDS #include "telnet.h" static uint16_t term_width, term_height; @@ -109,6 +109,7 @@ void telnet_echo_off(void) { const unsigned char seq[] = { IAC, WILL, TELOPT_ECHO, + IAC, DONT, TELOPT_ECHO, }; out_raw(seq, ARRAYLEN(seq)); } @@ -117,6 +118,7 @@ void telnet_echo_on(void) { const unsigned char seq[] = { IAC, WONT, TELOPT_ECHO, + IAC, DO, TELOPT_ECHO, }; out_raw(seq, ARRAYLEN(seq)); } |