From 23d2f670808933aa20448194b2a4ff26386d7905 Mon Sep 17 00:00:00 2001 From: Thorsten Töpper Date: Thu, 14 Aug 2025 21:34:19 +0200 Subject: tree_based_check: switch to unsigned values --- include/hex_conversion.h | 14 +++++++------- src/tree_based_check.c | 24 +++++++++++++----------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/hex_conversion.h b/include/hex_conversion.h index 4b97d6d..e232b8e 100644 --- a/include/hex_conversion.h +++ b/include/hex_conversion.h @@ -15,9 +15,9 @@ #define ishex_macro(c) ((c>='0' && c <= '9') || (c>='A' && c <= 'F') || (c>='a' && c <= 'f')) int convert_line(char *s); -int ishex(char c); -char *convert_to_binary(char *hex, char *out); -char *convert_from_binary(char *bin, size_t l, char *out); +int ishex(unsigned char c); +unsigned char *convert_to_binary(char *hex, unsigned char *out); +char *convert_from_binary(unsigned char *bin, size_t l, char *out); /* short inline functions are fine in header */ inline int convert_line(char *s) { @@ -35,14 +35,14 @@ inline int convert_line(char *s) { return 0; } -inline int ishex(char c) { +inline int ishex(unsigned char c) { if ((c>='0' && c <= '9') || (c>='A' && c <= 'F') || (c>='a' && c <= 'f')) { return 1; } return 0; }; -inline char *convert_to_binary(char *hex, char *out) { +inline unsigned char *convert_to_binary(char *hex, unsigned char *out) { char tmp[3] = {0,0,0}; size_t length, i; if (hex == NULL) return NULL; @@ -65,14 +65,14 @@ inline char *convert_to_binary(char *hex, char *out) { for (i=0;i 0 NOT FOUND */ -inline int check_tree_for_data(struct tree_root *root, char *data) { +inline int check_tree_for_data(struct tree_root *root, unsigned char *data) { int depth = 0; struct tree_branch *ptr; unsigned char uc; @@ -391,7 +391,8 @@ struct tree_root *read_file_into_tree(char *filename) { size_t line_nr=0; struct tree_root *root = NULL; FILE *fd = NULL; - char *line = NULL, *data = NULL; + char *line = NULL; + unsigned char *data = NULL; if (filename == NULL || strlen(filename) == 0) { return NULL; @@ -461,7 +462,8 @@ struct tree_root *read_file_into_tree(char *filename) { int filter_file_with_tree(char *filename, FILE *output, struct tree_root *root) { size_t line_nr=0; FILE *fd = NULL; - char *line = NULL, *data = NULL; + char *line = NULL; + unsigned char *data = NULL; int check_result = 0; int rc = 0; -- cgit v1.2.3-70-g09d2