diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2021-10-14 00:20:14 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2021-10-14 00:20:14 +0200 |
commit | 6a7eabbfee8c8df1a21f3da6e0fd5643c40ee607 (patch) | |
tree | 4977b44281abe1554a985dea00302c1608df8e7b | |
parent | e7bacdee090f62937eba802647b08f1a2657c7d9 (diff) |
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | aes.c | 13 | ||||
-rw-r--r-- | progressbar.c | 14 |
3 files changed, 17 insertions, 12 deletions
@@ -3,7 +3,7 @@ INSTALL_DIR := install -d INSTALL_BIN := install -s CFLAGS := -Wall -ffunction-sections -fdata-sections -ffast-math -fomit-frame-pointer -fexpensive-optimizations -Wl,--gc-sections ifneq ($(strip $(DEBUG)),) -CFLAGS += -Og -g +CFLAGS += -Og -g3 ifneq ($(strip $(DEBUG_ASAN)),) CFLAGS += -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak -fsanitize=undefined endif @@ -41,11 +41,10 @@ typedef struct { void aes_init(); aes_ctx_t *aes_alloc_ctx(unsigned char *key, size_t keyLen); -inline unsigned long aes_subword(unsigned long w); -inline unsigned long aes_rotword(unsigned long w); +unsigned long aes_subword(unsigned long w); +unsigned long aes_rotword(unsigned long w); void aes_keyexpansion(aes_ctx_t *ctx); - -inline unsigned char aes_mul_manual(unsigned char a, unsigned char b); // use aes_mul instead +unsigned char aes_mul_manual(unsigned char a, unsigned char b); // use aes_mul instead void aes_subbytes(aes_ctx_t *ctx); void aes_shiftrows(aes_ctx_t *ctx); @@ -204,7 +203,7 @@ aes_ctx_t *aes_alloc_ctx(unsigned char *key, size_t keyLen) return ctx; } -inline unsigned long aes_subword(unsigned long w) +unsigned long aes_subword(unsigned long w) { return g_aes_sbox[w & 0x000000ff] | (g_aes_sbox[(w & 0x0000ff00) >> 8] << 8) | @@ -212,7 +211,7 @@ inline unsigned long aes_subword(unsigned long w) (g_aes_sbox[(w & 0xff000000) >> 24] << 24); } -inline unsigned long aes_rotword(unsigned long w) +unsigned long aes_rotword(unsigned long w) { // May seem a bit different from the spec // It was changed because unsigned long is represented with little-endian convention on x86 @@ -241,7 +240,7 @@ void aes_keyexpansion(aes_ctx_t *ctx) } } -inline unsigned char aes_mul_manual(unsigned char a, unsigned char b) +unsigned char aes_mul_manual(unsigned char a, unsigned char b) { register unsigned short ac; register unsigned char ret; diff --git a/progressbar.c b/progressbar.c index 46ffe66..519f130 100644 --- a/progressbar.c +++ b/progressbar.c @@ -169,6 +169,12 @@ static int setup_file_info(struct file_info * const finfo, int proc_fd_fd, int p finfo->proc_fdinfo_fd = proc_fdinfo_fd; finfo->current_position = 0; finfo->max_size = buf.st_size; + + if (finfo->max_size == 0) { + fprintf(stderr, "setup_file_info: fd does not have any max size, probably a special file\n"); + return -1; + } + return 0; } @@ -475,7 +481,7 @@ static void show_progressbar(struct terminal const * const term, return; } /* do not show progressbar if someone writes/appendes to this file */ - if (finfo->current_position > finfo->max_size) { + if (finfo->max_size == 0 || finfo->current_position > finfo->max_size) { return; } @@ -484,7 +490,7 @@ static void show_progressbar(struct terminal const * const term, remaining_len = remaining_printable_chars(term, finfo); - float printable_progress = progress * (remaining_len - 2); + float printable_progress = progress * (remaining_len - 2.); memset(buf, '-', remaining_len - 2); memset(buf, '#', (size_t)printable_progress); buf[remaining_len - 2] = '\0'; @@ -586,7 +592,7 @@ int main(int argc, char ** argv) { struct filtered_dir_entries proc_pid_entries = {}; struct filtered_dir_entries proc_fd_entries = {}; - size_t target_filepath_len; + ssize_t target_filepath_len; char file_realpath[BUFSIZ] = {}; size_t found_targets = 0; struct filepath * paths = NULL; @@ -608,7 +614,7 @@ int main(int argc, char ** argv) } for (size_t j = 0; j < proc_fd_entries.entries_num; ++j) { - size_t realpath_used = realpath_procfs_fd("/proc", + ssize_t realpath_used = realpath_procfs_fd("/proc", proc_pid_entries.entries[i]->d_name, proc_fd_entries.entries[j]->d_name, &file_realpath[0], sizeof file_realpath - 1); |