diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 19 | ||||
| -rwxr-xr-x | src/depend.sh | 14 | ||||
| -rw-r--r-- | src/encryption.c | 3 | ||||
| -rw-r--r-- | src/encryption.h | 2 | ||||
| -rw-r--r-- | src/shared.c | 4 |
5 files changed, 27 insertions, 15 deletions
diff --git a/src/Makefile b/src/Makefile index 53cd9fd..88c5344 100644 --- a/src/Makefile +++ b/src/Makefile | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | CC = gcc | 1 | CC = gcc |
| 2 | SHELL = /usr/bin/env -S bash | 2 | SHELL := bash |
| 3 | 3 | ||
| 4 | # I need to get better at makefiles so I can write this in a way that isn't absolutely insane/stupid | 4 | # I need to get better at makefiles so I can write this in a way that isn't absolutely insane/stupid |
| 5 | # RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto | 5 | # RELEASE_CFLAGS := -O3 -fipa-pta -fipa-cp -fuse-linker-plugin -flto=auto |
| @@ -9,24 +9,23 @@ CFLAGS = -std=c2x -Wall -Wextra -Wpedantic -pedantic-errors -fanalyzer -Wanalyze | |||
| 9 | LDLIBS += $$(pkg-config --libs-only-l libsodium) | 9 | LDLIBS += $$(pkg-config --libs-only-l libsodium) |
| 10 | LDFLAGS += $$(pkg-config --libs-only-L libsodium) | 10 | LDFLAGS += $$(pkg-config --libs-only-L libsodium) |
| 11 | 11 | ||
| 12 | OBJECTS := $(patsubst %.c,%.o, $(wildcard *.c)) | 12 | SOURCES := $(wildcard *.c) |
| 13 | OBJECTS := $(patsubst %.c,%.o,$(SOURCES)) | ||
| 14 | DEPS := $(patsubst %.c,%.dep,$(SOURCES)) | ||
| 13 | 15 | ||
| 14 | .PHONY: all c clean val | 16 | .PHONY: all c clean val |
| 15 | .DELETE_ON_ERROR: | 17 | .DELETE_ON_ERROR: |
| 18 | .ONESHELL: | ||
| 16 | 19 | ||
| 17 | all: main | 20 | all: main |
| 18 | main: main.o encryption.o shared.o ll.o arena.o | 21 | main: main.o encryption.o shared.o ll.o arena.o |
| 19 | 22 | ||
| 20 | 23 | $(OBJECTS): %.o: %.dep | |
| 21 | $(OBJECTS): shared.h | 24 | %.dep: %.c |
| 22 | ll.o: ll.c ll.h | 25 | ./depend.sh `dirname $*` $(CFLAGS) $*.c > $@ |
| 23 | main.o: main.c | ||
| 24 | arena.o: arena.c arena.h | ||
| 25 | shared.o: shared.c shared.h # Might as well put shared.h in here explicitly | ||
| 26 | encryption.o: encryption.c encryption.h | ||
| 27 | 26 | ||
| 28 | c clean: | 27 | c clean: |
| 29 | -rm -rv main $(OBJECTS) $(wildcard *.test*) $(wildcard *.enc) | 28 | @-rm -rv main $(OBJECTS) $(DEPS) $(wildcard *.test*) $(wildcard *.enc) |
| 30 | 29 | ||
| 31 | val: | 30 | val: |
| 32 | $(MAKE) all | 31 | $(MAKE) all |
diff --git a/src/depend.sh b/src/depend.sh new file mode 100755 index 0000000..b6084b1 --- /dev/null +++ b/src/depend.sh | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | DIR="$1" | ||
| 3 | shift 1 | ||
| 4 | case "$DIR" in | ||
| 5 | "" | ".") | ||
| 6 | gcc -MM -MG "$@" | sed -e "s@^\(.*\)\.o:@\1.d \1.o:@" | ||
| 7 | ;; | ||
| 8 | *) | ||
| 9 | gcc -MM -MG "$@" | sed -e "s@^\(.*\)\.o:@$DIR/\1.d $DIR/\1.o:@" | ||
| 10 | ;; | ||
| 11 | esac | ||
| 12 | |||
| 13 | # Shamelessly stolen from Peter Miller's "Recursive Make Considered Harmful" | ||
| 14 | # https://web.archive.org/web/20250404190928/https://aegis.sourceforge.net/auug97.pdf \ No newline at end of file | ||
diff --git a/src/encryption.c b/src/encryption.c index 4ff37cc..3530eed 100644 --- a/src/encryption.c +++ b/src/encryption.c | |||
| @@ -255,8 +255,7 @@ int decrypttofile(FILE *src, FILE *dst, const unsigned char key[crypto_secretstr | |||
| 255 | 255 | ||
| 256 | int genpassword(char **str, unsigned int words) { | 256 | int genpassword(char **str, unsigned int words) { |
| 257 | // Early returns | 257 | // Early returns |
| 258 | if(words < 1) | 258 | if(words < 1) {return 0;} |
| 259 | return 0; | ||
| 260 | #if ___VXGG___ALWAYS_CHECK_LIBSODIUM___ > 0 | 259 | #if ___VXGG___ALWAYS_CHECK_LIBSODIUM___ > 0 |
| 261 | checksodium(); | 260 | checksodium(); |
| 262 | #endif | 261 | #endif |
diff --git a/src/encryption.h b/src/encryption.h index b02216f..f6c018c 100644 --- a/src/encryption.h +++ b/src/encryption.h | |||
| @@ -32,7 +32,7 @@ void vxgg_setsodiumfailcb(const vxgg_naclfailcb cb, void *data); | |||
| 32 | 32 | ||
| 33 | // Fuck reading from a file. Even if someone ran strings on the binary and got this they wouldn't be able to regenerate the key | 33 | // Fuck reading from a file. Even if someone ran strings on the binary and got this they wouldn't be able to regenerate the key |
| 34 | #define PASSWORD_WORDS (\ | 34 | #define PASSWORD_WORDS (\ |
| 35 | (const char *[]){\ | 35 | (const char * const []){\ |
| 36 | "the", "of", "to", "and", "for", "our", "their", "has", "in", "he", "a", "them", "that", "these", "by", "have", "we", \ | 36 | "the", "of", "to", "and", "for", "our", "their", "has", "in", "he", "a", "them", "that", "these", "by", "have", "we", \ |
| 37 | "us", "people", "which", "all", "is", "with", "laws", "be", "are", "his", "states", "on", "they", "right", "it", "from", \ | 37 | "us", "people", "which", "all", "is", "with", "laws", "be", "are", "his", "states", "on", "they", "right", "it", "from", \ |
| 38 | "government", "such", "among", "powers", "most", "an", "time", "should", "new", "as", "been", "colonies", "assent", \ | 38 | "government", "such", "among", "powers", "most", "an", "time", "should", "new", "as", "been", "colonies", "assent", \ |
diff --git a/src/shared.c b/src/shared.c index 093e766..bec0354 100644 --- a/src/shared.c +++ b/src/shared.c | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | #include <errno.h> | 6 | #include <errno.h> |
| 7 | #include <error.h> | 7 | #include <error.h> |
| 8 | 8 | ||
| 9 | static enum XALLOC_TYPE { | 9 | enum XALLOC_TYPE { |
| 10 | XALLOC_INVAL, // Default when unset | 10 | XALLOC_INVAL, // Default when unset |
| 11 | 11 | ||
| 12 | XALLOC_MALLOC, | 12 | XALLOC_MALLOC, |
| @@ -120,7 +120,7 @@ int rwbuf(char **str, unsigned long int initsize, int fd) { | |||
| 120 | int wwbuf(int fd, const unsigned char *buf, int len) { | 120 | int wwbuf(int fd, const unsigned char *buf, int len) { |
| 121 | int total = 0; | 121 | int total = 0; |
| 122 | int left = len; | 122 | int left = len; |
| 123 | int n; | 123 | int n = -1; |
| 124 | 124 | ||
| 125 | while(total < len) { | 125 | while(total < len) { |
| 126 | if((n = write(fd, buf + total, left)) < 0) | 126 | if((n = write(fd, buf + total, left)) < 0) |
