Compare commits

...

5 Commits

Author SHA1 Message Date
Adrien Gallouët
c113724eb0 Update mud
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-25 20:47:47 +00:00
Adrien Gallouët
b184ddedaa Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-25 10:33:47 +00:00
Adrien Gallouët
28a978f276 Fix the last fix :)
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-25 07:32:34 +00:00
Adrien Gallouët
e0546ec46a Fix build on OpenBSD
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-24 17:41:58 +00:00
Adrien Gallouët
50f002b7f8 Add variable X to cross build a static binary
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-24 09:27:36 +00:00
4 changed files with 23 additions and 13 deletions

View File

@@ -2,31 +2,31 @@ NAME := glorytun
VERSION := $(shell ./version.sh) VERSION := $(shell ./version.sh)
DIST := $(NAME)-$(VERSION) DIST := $(NAME)-$(VERSION)
CFLAGS ?= -std=c11 -O2 -Wall -fstack-protector-strong
FLAGS := $(CFLAGS) $(LDFLAGS) $(CPPFLAGS)
CC ?= cc CC ?= cc
prefix ?= /usr prefix ?= /usr
Q := @ Q := @
CFLAGS := -std=c11 -O2 -Wall -fstack-protector-strong ifneq ($(X),)
H = $(X)-
FLAGS += -static
endif
FLAGS := $(CFLAGS) $(LDFLAGS) $(CPPFLAGS)
FLAGS += -DPACKAGE_NAME=\"$(NAME)\" -DPACKAGE_VERSION=\"$(VERSION)\" FLAGS += -DPACKAGE_NAME=\"$(NAME)\" -DPACKAGE_VERSION=\"$(VERSION)\"
FLAGS += -I.static/$(X)/libsodium-stable/src/libsodium/include
FLAGS += -I.static/$(CROSS)/libsodium-stable/src/libsodium/include FLAGS += -L.static/$(X)/libsodium-stable/src/libsodium/.libs
FLAGS += -L.static/$(CROSS)/libsodium-stable/src/libsodium/.libs
SRC := argz/argz.c mud/mud.c mud/aegis256/aegis256.c $(wildcard src/*.c) SRC := argz/argz.c mud/mud.c mud/aegis256/aegis256.c $(wildcard src/*.c)
HDR := argz/argz.h mud/mud.h mud/aegis256/aegis256.h $(wildcard src/*.h) HDR := argz/argz.h mud/mud.h mud/aegis256/aegis256.h $(wildcard src/*.h)
ifneq ($(CROSS),)
X = $(CROSS)-
endif
$(NAME): $(SRC) $(HDR) $(NAME): $(SRC) $(HDR)
$(Q)$(X)$(CC) $(FLAGS) -o $(NAME) $(SRC) -lsodium $(Q)$(H)$(CC) $(FLAGS) -o $(NAME) $(SRC) -lsodium
$(NAME)-strip: $(NAME) $(NAME)-strip: $(NAME)
$(Q)cp $< $@ $(Q)cp $< $@
$(Q)$(X)strip -x $@ $(Q)$(H)strip -x $@
.PHONY: install .PHONY: install
install: $(NAME)-strip install: $(NAME)-strip

2
mud

Submodule mud updated: bda2c6eaa7...c426cef08b

View File

@@ -12,6 +12,8 @@
#include <errno.h> #include <errno.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifndef PACKAGE_NAME #ifndef PACKAGE_NAME
#define PACKAGE_NAME "glorytun" #define PACKAGE_NAME "glorytun"

View File

@@ -131,13 +131,21 @@ tun_create_by_name(char *name, size_t len, const char *dev_name)
static int static int
tun_create_by_name(char *name, size_t len, const char *dev_name) tun_create_by_name(char *name, size_t len, const char *dev_name)
{ {
int ret = snprintf(name, len, "/dev/%s", dev_name); int ret = snprintf(name, len, "%s", dev_name);
if (ret <= 0 || (size_t)ret >= len) { if (ret <= 0 || (size_t)ret >= len) {
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
char tmp[64];
ret = snprintf(tmp, sizeof(tmp), "/dev/%s", dev_name);
if (ret <= 0 || (size_t)ret >= sizeof(tmp)) {
errno = EINVAL;
return -1;
}
return open(tmp, O_RDWR); return open(tmp, O_RDWR);
} }