Compare commits

...

2 Commits

Author SHA1 Message Date
Freya Murphy e065c4f8ef
fix use after free 2023-12-14 13:07:18 -05:00
trimill b2ca9fb81a
a 2023-12-14 13:05:17 -05:00
2 changed files with 8 additions and 1 deletions

View File

@ -1,4 +1,5 @@
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
@ -54,8 +55,9 @@ int tel_get_addr(char *ip, char *port, struct sockaddr **addr, socklen_t *addr_l
int res = getaddrinfo(ip, port, &hints, &info);
if(res != 0) return res;
*addr = info->ai_addr;
*addr = malloc(info->ai_addrlen);
*addr_len = info->ai_addrlen;
memcpy(*addr, info->ai_addr, info->ai_addrlen);
freeaddrinfo(info);
return 0;

5
teld.c
View File

@ -157,6 +157,7 @@ void client_pickup(struct call_buf *call_buf, int stream) {
union tel_sa_any remote_addr;
socklen_t remote_addr_len = sizeof(union tel_sa_any);
res = tel_read_sockaddr(stream, &remote_addr, &remote_addr_len);
if(res < 0) goto err;
int idx = call_buf_search(call_buf, &remote_addr);
if(idx < 0) {
@ -175,6 +176,10 @@ void client_pickup(struct call_buf *call_buf, int stream) {
};
close(fd);
return;
err:
printf("error picking up call: %s\n", strerror(errno));
tel_write_err(stream, strerror(errno));
}
void client_call(int stream, struct config cfg) {