Skip to content
Snippets Groups Projects
Commit 4a14bf12 authored by deuce's avatar deuce
Browse files

Fix handling of client_t char * fields.

parent 954b9c2a
No related branches found
No related tags found
No related merge requests found
......@@ -267,6 +267,7 @@ void status_client_on(enum sbbs_status_service svc, BOOL on, SOCKET sock, client
{
struct sbbs_status_msg *msg;
size_t sz;
char *p;
pthread_once(&init_once, init_lists);
pthread_mutex_lock(&status_mutex[svc]);
......@@ -288,7 +289,7 @@ void status_client_on(enum sbbs_status_service svc, BOOL on, SOCKET sock, client
pthread_mutex_unlock(&status_mutex[svc]);
if (status_sock.count == 0)
return;
sz = offsetof(struct sbbs_status_msg, msg.client_on) + sizeof(msg->msg.client_on);
sz = offsetof(struct sbbs_status_msg, msg.client_on) + sizeof(msg->msg.client_on) + strlen(client->protocol) + 1 + strlen(client->user) + 1;
msg = malloc(sz);
if (msg == NULL)
return;
......@@ -299,6 +300,10 @@ void status_client_on(enum sbbs_status_service svc, BOOL on, SOCKET sock, client
msg->msg.client_on.sock = sock;
msg->msg.client_on.client = *client;
msg->msg.client_on.update = update;
strcpy(msg->msg.client_on.strdata, client->protocol ? client->protocol : "<null>");
p = strchr(msg->msg.client_on.strdata, 0);
p++;
strcpy(p, client->user ? client->user : "<null>");
sendsmsg(msg);
free(msg);
}
......
......@@ -73,6 +73,7 @@ struct sbbs_status_msg {
SOCKET sock;
client_t client;
BOOL update;
char strdata[];
} client_on;
struct {
uint64_t error_count;
......
......@@ -16,6 +16,7 @@ int main(int argc, char **argv)
socklen_t addrlen;
char *buf[4096];
struct sbbs_status_msg *msg;
time_t t;
if (argc != 2) {
usage();
......@@ -75,7 +76,19 @@ int main(int argc, char **argv)
printf("%d clients\n", msg->msg.clients.active);
break;
case STATUS_CLIENT_ON:
printf("got client_on\n");
t = msg->msg.client_on.client.time; /* sigh */
msg->msg.client_on.client.protocol = msg->msg.client_on.strdata;
msg->msg.client_on.client.user = strchr(msg->msg.client_on.strdata, 0)+1;
printf("Client %s%s: sock: %d\n addr: %s\n host: %s\n port: %" PRIu16 "\n %s at %s via %s",
msg->msg.client_on.on ? "on" : "off",
msg->msg.client_on.update ? " update" : "",
msg->msg.client_on.sock,
msg->msg.client_on.client.addr,
msg->msg.client_on.client.host,
msg->msg.client_on.client.port,
msg->msg.client_on.client.user,
ctime(&t),
msg->msg.client_on.client.protocol);
break;
case STATUS_ERRORMSG:
printf("%d - %s\n", msg->msg.errormsg.level, msg->msg.errormsg.msg);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment