Added compilation option for sakisafecli to use strlcpy on Linux systems

master
Barrington 2022-11-12 14:41:00 +01:00
parent 955985b825
commit b39bd3bc5b
3 changed files with 22 additions and 11 deletions

View File

@ -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

View File

@ -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",

View File

@ -9,7 +9,9 @@
#include <curl/curl.h>
#include <sys/stat.h>
#include <errno.h>
#ifdef use_libbsd
#include <bsd/string.h>
#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;