aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--general_network.c29
-rw-r--r--psuedoclients/haxserv.c3
-rw-r--r--server_network.c4
3 files changed, 29 insertions, 7 deletions
diff --git a/general_network.c b/general_network.c
index 5a2bda2..2b055c2 100644
--- a/general_network.c
+++ b/general_network.c
@@ -122,8 +122,29 @@ struct table server_list = {0};
struct table user_list = {0};
struct table channel_list = {0};
-// TODO: Proper string handling
int resolve(struct string address, struct string port, struct sockaddr *sockaddr) {
+ // NULL isn't really valid in this anyways so... just checking it and replacing with null-terminated for now
+ for (size_t i = 0; i < address.len; i++)
+ if (address.data[i] == 0)
+ return 1;
+ for (size_t i = 0; i < port.len; i++)
+ if (port.data[i] == 0)
+ return 1;
+
+ char *addr_null = malloc(address.len+1);
+ if (!addr_null)
+ return 1;
+ memcpy(addr_null, address.data, address.len);
+ addr_null[address.len] = 0;
+
+ char *port_null = malloc(port.len+1);
+ if (!port_null) {
+ free(addr_null);
+ return 1;
+ }
+ memcpy(port_null, port.data, port.len);
+ port_null[port.len] = 0;
+
int success;
struct addrinfo hints = {
.ai_family = AF_INET,
@@ -133,13 +154,15 @@ int resolve(struct string address, struct string port, struct sockaddr *sockaddr
};
struct addrinfo *info;
- success = getaddrinfo(address.data, port.data, &hints, &info);
+ success = getaddrinfo(addr_null, port_null, &hints, &info);
if (success == 0) {
*sockaddr = *(info->ai_addr);
freeaddrinfo(info);
}
+ free(port_null);
+ free(addr_null);
return success;
}
@@ -614,7 +637,7 @@ int privmsg(struct string from, struct string sender, struct string target, stru
send = 0;
for (size_t i = 0; i < channel->user_list.len; i++) {
struct user_info *user = channel->user_list.array[i].ptr;
- if (user->is_psuedoclient && user->psuedoclient == HAXSERV_PSUEDOCLIENT) {
+ if (user->is_psuedoclient && user->psuedoclient == HAXSERV_PSUEDOCLIENT && !STRING_EQ(sender, user->uid)) {
send = 1;
break;
}
diff --git a/psuedoclients/haxserv.c b/psuedoclients/haxserv.c
index dd6562c..2d80a2a 100644
--- a/psuedoclients/haxserv.c
+++ b/psuedoclients/haxserv.c
@@ -86,9 +86,6 @@ int haxserv_psuedoclient_allow_kick(struct string from, struct string source, st
}
void haxserv_psuedoclient_handle_privmsg(struct string from, struct string source, struct string target, struct string msg) {
- if (STRING_EQ(source, HAXSERV_UID))
- return;
-
struct string respond_to;
struct string prefix;
diff --git a/server_network.c b/server_network.c
index 7a0b735..1afd370 100644
--- a/server_network.c
+++ b/server_network.c
@@ -158,8 +158,10 @@ void * server_accept_thread(void *type) {
struct string address;
void *con_handle;
int con_fd = networks[net].accept(listen_fd, &con_handle, &address);
- if (con_fd == -1)
+ if (con_fd == -1) {
+ sleep(60);
continue; // TODO: Handle error
+ }
pthread_t trash;
struct server_connection_info *info;