From b39bd3bc5b60caa7b85bb580a089c249ea1705b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Palomares=20Pizarro?= Date: Sat, 12 Nov 2022 14:41:00 +0100 Subject: [PATCH] Added compilation option for sakisafecli to use strlcpy on Linux systems --- sakisafecli/Makefile | 17 +++++++++++++---- sakisafecli/funcs.c | 4 ++-- sakisafecli/sakisafecli.c | 12 +++++++----- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/sakisafecli/Makefile b/sakisafecli/Makefile index 28dacd0..d0c2c36 100644 --- a/sakisafecli/Makefile +++ b/sakisafecli/Makefile @@ -1,9 +1,18 @@ -PROG = sakisafecli -SRCS += funcs.c sakisafecli.c config.c -MAN = sakisafecli.1 sakisafeclirc.5 -LDADD = -lssl -lz -lpthread -lnghttp2 -lcurl -lconfig -lcrypto -L/usr/local/lib + +PROG += sakisafecli +SRCS += funcs.c sakisafecli.c config.c +MAN += sakisafecli.1 sakisafeclirc.5 +LDADD += -lssl -lz -lpthread -lnghttp2 -lcurl -lconfig -lcrypto -L/usr/local/lib PREFIX = /usr/local +# Use libbsd features if wanted +use-libbsd ?= no +.if ${use-libbsd} == "yes" +CFLAGS += -Duse_libbsd +LDADD += -lbsd +.endif + +BINMODE = 755 BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/man/man diff --git a/sakisafecli/funcs.c b/sakisafecli/funcs.c index 1c992fd..b514ece 100644 --- a/sakisafecli/funcs.c +++ b/sakisafecli/funcs.c @@ -27,9 +27,9 @@ print_help() "server\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", "-t|--token: Authentication token (https://u.kalli.st)", "-P|--http-proxy: http proxy to use e.g. http://127.0.0.1:4444", - "-p|--socks-proxy: SOCK proxy to use e.g. 127.0.0.1:9050", + "-p|--socks-proxy: SOCK proxy to use e.g.I 127.0.0.1:9050", "-6|--ipv6: uses IPv6 only", - "-4|--ipv6: uses IPv4 only", + "-4|--ipv6: uses IPv4 only", "-S|--silent: doesn't print progress", "-x|--paste: read file from stdin", "-C: print current settings", diff --git a/sakisafecli/sakisafecli.c b/sakisafecli/sakisafecli.c index 824045b..d1fd567 100644 --- a/sakisafecli/sakisafecli.c +++ b/sakisafecli/sakisafecli.c @@ -9,7 +9,9 @@ #include #include #include - +#ifdef use_libbsd +#include +#endif #include "curl/easy.h" #include "options.h" #include "config.h" @@ -56,7 +58,7 @@ main(int argc, char **argv) fclose(fp); } } else { -#if defined(__OpenBSD__) || defined(__FreeBSD__) +#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(use_libbsd) strlcpy(config_location, sakisafeclirc_env, 512); #else /* Linux sucks! */ strncpy(config_location, sakisafeclirc_env, 512); @@ -236,11 +238,11 @@ main(int argc, char **argv) char path[256]; char *filename = argv[optind]; - + curl_easy_setopt(easy_handle, CURLOPT_UPLOAD, true); FILE *fp = fopen(filename, "r"); if(fp == NULL) { - fprintf(stderr, "%s",strerror(errno)); + fprintf(stderr, "%s", strerror(errno)); exit(-1); } @@ -256,7 +258,7 @@ main(int argc, char **argv) if(ret != 0) { fprintf(stderr, "%i: %s\n", ret, curl_easy_strerror(ret)); } - + } else { puts("Unsupported protocol"); return -1;