summaryrefslogtreecommitdiff
path: root/pullreqd.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-06-11 19:38:57 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2021-06-11 19:38:57 -0400
commitbfd3904c4439680060948402ed546ffa3532be67 (patch)
tree8569e086590165b50356530aed300a81cedb070c /pullreqd.c
parent27f41f410d78403abecbaf9264d8a9abbac39f32 (diff)
Change `port` from an int to a string, and move the
valid port check into the config parser.
Diffstat (limited to 'pullreqd.c')
-rw-r--r--pullreqd.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/pullreqd.c b/pullreqd.c
index a00d85c..f077a50 100644
--- a/pullreqd.c
+++ b/pullreqd.c
@@ -109,15 +109,8 @@ int init_socket(config *cfg) {
sock_addr.sa_un.sun_family = sock_type;
memcpy(sock_addr.sa_un.sun_path, cfg->sock, path_length+1);
} else {
- if (cfg->port <= 0 || cfg->port > 65535) {
- syslog(LOG_ERR, "Invalid port %d. (Valid port must be between 1, and 65535.)", cfg->port);
- return -1;
- }
struct addrinfo hints, *ainfo_root, *ainfo;
- const size_t size = snprintf(NULL, 0, "%d", cfg->port) + 1;
- char *port_str = malloc(size);
- sprintf(port_str, "%d", cfg->port);
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
@@ -125,7 +118,7 @@ int init_socket(config *cfg) {
/*hints.ai_protocol = IPPROTO_SCTP;*/
hints.ai_flags = AI_PASSIVE;
- const int gai_ret = getaddrinfo(cfg->sock, port_str, &hints, &ainfo_root);
+ const int gai_ret = getaddrinfo(cfg->sock, cfg->port, &hints, &ainfo_root);
/* Did getaddrinfo fail? */
if (gai_ret) {
syslog(LOG_ERR, "getaddrinfo() failed for hostname %s. Reason: %s", cfg->sock, gai_strerror(gai_ret));