diff --git a/qrexec-lib/Makefile b/qrexec-lib/Makefile index 3c918220..2b7eec4c 100644 --- a/qrexec-lib/Makefile +++ b/qrexec-lib/Makefile @@ -1,5 +1,5 @@ CC=gcc -CFLAGS := $(CFLAGS) -I. -g3 -O2 -Wall -Wextra -Werror -pie -fPIC +CFLAGS := $(CFLAGS) -I. -g3 -O2 -Wall -Wextra -Werror -pie -fPIC -Wmissing-declarations -Wmissing-prototypes SO_VER=2 LDFLAGS+=-Wl,--no-undefined,--as-needed,-Bsymbolic -L . .PHONY: all clean install check diff --git a/qrexec-lib/crc32.c b/qrexec-lib/crc32.c index 88b06277..8fb8c2af 100644 --- a/qrexec-lib/crc32.c +++ b/qrexec-lib/crc32.c @@ -29,46 +29,6 @@ unsigned long Crc32_ComputeBuf( unsigned long inCrc32, const void *buf, size_t bufLen ); -/*----------------------------------------------------------------------------*\ - * NAME: - * Crc32_ComputeFile() - compute CRC-32 value for a file - * DESCRIPTION: - * Computes the CRC-32 value for an opened file. - * ARGUMENTS: - * file - file pointer - * outCrc32 - (out) result CRC-32 value - * RETURNS: - * err - 0 on success or -1 on error - * ERRORS: - * - file errors -\*----------------------------------------------------------------------------*/ - -int Crc32_ComputeFile( FILE *file, unsigned long *outCrc32 ) -{ -# define CRC_BUFFER_SIZE 8192 - unsigned char buf[CRC_BUFFER_SIZE]; - size_t bufLen; - - /** accumulate crc32 from file **/ - *outCrc32 = 0; - while (1) { - bufLen = fread( buf, 1, CRC_BUFFER_SIZE, file ); - if (bufLen == 0) { - if (ferror(file)) { - fprintf( stderr, "error reading file\n" ); - goto ERR_EXIT; - } - break; - } - *outCrc32 = Crc32_ComputeBuf( *outCrc32, buf, bufLen ); - } - return( 0 ); - - /** error exit **/ -ERR_EXIT: - return( -1 ); -} - /*----------------------------------------------------------------------------*\ * NAME: * Crc32_ComputeBuf() - computes the CRC-32 value of a memory buffer diff --git a/qrexec-lib/ioall.c b/qrexec-lib/ioall.c index 7a3f249a..38619f2d 100644 --- a/qrexec-lib/ioall.c +++ b/qrexec-lib/ioall.c @@ -24,8 +24,9 @@ #include #include #include +#include "libqubes-rpc-filecopy.h" -void perror_wrapper(const char * msg) +static void perror_wrapper(const char * msg) { int prev=errno; perror(msg); diff --git a/qrexec-lib/unpack.c b/qrexec-lib/unpack.c index 3aa363c9..eb8b69fc 100644 --- a/qrexec-lib/unpack.c +++ b/qrexec-lib/unpack.c @@ -45,7 +45,7 @@ void send_status_and_crc(int code, const char *last_filename); #define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT) #endif -_Noreturn void do_exit(int code, const char *last_filename) +static _Noreturn void do_exit(int code, const char *last_filename) { close(0); send_status_and_crc(code, last_filename); @@ -74,7 +74,7 @@ void set_procfs_fd(int value) use_tmpfile = 1; } -int wait_for_space(int fd, unsigned long how_much) { +static int wait_for_space(int fd, unsigned long how_much) { int counter = 0; struct statvfs fs_space; do { @@ -91,7 +91,7 @@ int wait_for_space(int fd, unsigned long how_much) { } static unsigned long crc32_sum = 0; -int read_all_with_crc(int fd, void *buf, int size) { +static int read_all_with_crc(int fd, void *buf, int size) { int ret; ret = read_all(fd, buf, size); if (ret) @@ -196,8 +196,8 @@ static int opendir_safe(int dirfd, char *path, const char **last_segment) } } -void process_one_file_reg(struct file_header *untrusted_hdr, - const char *untrusted_name) +static void process_one_file_reg(struct file_header *untrusted_hdr, + const char *untrusted_name) { int ret; int fdout = -1, safe_dirfd; @@ -260,8 +260,8 @@ void process_one_file_reg(struct file_header *untrusted_hdr, } -void process_one_file_dir(struct file_header *untrusted_hdr, - const char *untrusted_name) +static void process_one_file_dir(struct file_header *untrusted_hdr, + const char *untrusted_name) { int safe_dirfd; const char *last_segment; @@ -291,8 +291,8 @@ void process_one_file_dir(struct file_header *untrusted_hdr, free(path_dup); } -void process_one_file_link(struct file_header *untrusted_hdr, - const char *untrusted_name) +static void process_one_file_link(struct file_header *untrusted_hdr, + const char *untrusted_name) { char untrusted_content[MAX_PATH_LENGTH]; const char *last_segment; @@ -331,7 +331,7 @@ void process_one_file_link(struct file_header *untrusted_hdr, free(path_dup); } -void process_one_file(struct file_header *untrusted_hdr, int flags) +static void process_one_file(struct file_header *untrusted_hdr, int flags) { unsigned int namelen; if (untrusted_hdr->namelen > MAX_PATH_LENGTH - 1)