From d8334865b489cb19dd898840b7c4eddd70e4180e Mon Sep 17 00:00:00 2001 From: dovecoteescapee Date: Sat, 2 Mar 2024 14:14:02 +0300 Subject: [PATCH 1/2] Replace perror calls with uniperror --- main.c | 6 +++--- proxy.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index b35bce4..507be26 100644 --- a/main.c +++ b/main.c @@ -360,7 +360,7 @@ int main(int argc, char **argv) case 'l': fake_tls.data = ftob(optarg, &fake_tls.size); if (!fake_tls.data) { - perror("read file"); + uniperror("read file"); return -1; } break; @@ -368,7 +368,7 @@ int main(int argc, char **argv) case 'o': fake_http.data = ftob(optarg, &fake_http.size); if (!fake_http.data) { - perror("read file"); + uniperror("read file"); return -1; } break; @@ -376,7 +376,7 @@ int main(int argc, char **argv) case 'e': oob_data.data = ftob(optarg, &oob_data.size); if (!oob_data.data) { - perror("read file"); + uniperror("read file"); return -1; } break; diff --git a/proxy.c b/proxy.c index 1589f1d..5067723 100644 --- a/proxy.c +++ b/proxy.c @@ -529,7 +529,7 @@ static inline int on_tunnel(struct poolhd *pool, struct eval *val, val->size = n - sn; if (!(val->tmpbuf = malloc(val->size))) { - perror("malloc"); + uniperror("malloc"); return -1; } memcpy(val->tmpbuf, buffer + sn, val->size); @@ -552,19 +552,19 @@ int event_loop(int srvfd) struct poolhd *pool = init_pool(params.max_open * 2 + 1); if (!pool) { - perror("init pool"); + uniperror("init pool"); close(srvfd); return -1; } if (!add_event(pool, EV_ACCEPT, srvfd, 0)) { - perror("add event"); + uniperror("add event"); destroy_pool(pool); close(srvfd); return -1; } char *buffer = malloc(params.bfsize); if (!buffer) { - perror("malloc"); + uniperror("malloc"); destroy_pool(pool); return -1; } From 9528a4421d110dc3fd7ef5901b3b110546ffd89b Mon Sep 17 00:00:00 2001 From: dovecoteescapee Date: Sat, 2 Mar 2024 19:13:55 +0300 Subject: [PATCH 2/2] Make change_tls_sni arg const --- packets.c | 2 +- packets.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packets.c b/packets.c index ab1b095..d6de09a 100644 --- a/packets.c +++ b/packets.c @@ -85,7 +85,7 @@ int find_tls_ext_offset(uint16_t type, char *data, size_t size) } -int change_tls_sni(char *host, char *buffer, size_t bsize) +int change_tls_sni(const char *host, char *buffer, size_t bsize) { int sni_offs, pad_offs; diff --git a/packets.h b/packets.h index e16b80b..a52b6a6 100644 --- a/packets.h +++ b/packets.h @@ -13,7 +13,7 @@ extern char tls_data[517]; extern char http_data[43]; -int change_tls_sni(char *host, char *buffer, size_t bsize); +int change_tls_sni(const char *host, char *buffer, size_t bsize); int parse_tls(char *buffer, size_t bsize, char **hs);