diff options
author | Trumeet <yuuta@yuuta.moe> | 2021-06-06 23:46:38 -0700 |
---|---|---|
committer | Trumeet <yuuta@yuuta.moe> | 2021-06-06 23:46:38 -0700 |
commit | b55296041b70c46c2949d8a176916e9ce8a4af7a (patch) | |
tree | 52af04bf61dd5aae77e7b3bf447bc1c9bd3cc8b8 | |
parent | af3d8d2ffb895293dcb75b3736c6184a2f21c502 (diff) | |
download | extmc-b55296041b70c46c2949d8a176916e9ce8a4af7a.tar extmc-b55296041b70c46c2949d8a176916e9ce8a4af7a.tar.gz extmc-b55296041b70c46c2949d8a176916e9ce8a4af7a.tar.bz2 extmc-b55296041b70c46c2949d8a176916e9ce8a4af7a.zip |
fix: use address sanitizer to fix two memory issues
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | main.c | 3 |
2 files changed, 3 insertions, 2 deletions
@@ -14,7 +14,7 @@ OBJ=main.o thpool.o mcin.o plugins.o rcon_host.o rcon.o net.o plugin_registry.o BIN=extmc -debug: CFLAGS += -DCONTROL_SOCKET_PATH="\"./extmc.ctl\"" -g3 -O0 -rdynamic +debug: CFLAGS += -fsanitize=address -DCONTROL_SOCKET_PATH="\"./extmc.ctl\"" -g3 -O0 -rdynamic debug: $(BIN) release: CFLAGS += -DDISABLE_DEBUG @@ -707,7 +707,7 @@ static int main_ctl(int argc, char **argv) length += strlen(argv[i]); if(i != argc - 1) length ++; } - char *dat = calloc(length, sizeof(char)); + char *dat = calloc(length + 1, sizeof(char)); strcpy(dat, ""); for(int i = 1; i < argc; i ++) { @@ -715,6 +715,7 @@ static int main_ctl(int argc, char **argv) if(i != argc - 1) strcat(dat, " "); } dprintf(fd, "%s", dat); + free(dat); ssize_t num_read; int arr_size = 1025; |