From 95a0aaef54240d7df075fbbe842954e8751c29f7 Mon Sep 17 00:00:00 2001 From: Pedro Folloni Pesserl Date: Sat, 24 Jun 2023 12:06:32 -0300 Subject: [PATCH] [vinapp] finish vinapp (frfr) --- vinapp/TODO | 1 - vinapp/src/extract.c | 4 ++++ vinapp/src/insert.c | 4 ++-- vinapp/src/remove.c | 4 ++++ 4 files changed, 10 insertions(+), 3 deletions(-) delete mode 100644 vinapp/TODO diff --git a/vinapp/TODO b/vinapp/TODO deleted file mode 100644 index ba201af..0000000 --- a/vinapp/TODO +++ /dev/null @@ -1 +0,0 @@ -investigar por que inserir diretorios grandes da errado diff --git a/vinapp/src/extract.c b/vinapp/src/extract.c index 437768f..b9d3e58 100644 --- a/vinapp/src/extract.c +++ b/vinapp/src/extract.c @@ -10,6 +10,10 @@ static void extract(FILE *archive, struct File_info *dir, size_t dirnmemb, char *member_name) { + size_t memb_name_size = strnlen(member_name, MAX_FNAME_LEN); + if (member_name[memb_name_size - 1] == '/') + member_name[memb_name_size - 1] = '\0'; + char std_name[MAX_FNAME_LEN] = {0}; standardize_name(member_name, std_name); size_t member_ord = get_ord(dir, dirnmemb, std_name); diff --git a/vinapp/src/insert.c b/vinapp/src/insert.c index b6a114b..4c9aa09 100644 --- a/vinapp/src/insert.c +++ b/vinapp/src/insert.c @@ -71,7 +71,7 @@ static void insert(FILE *archive, struct File_info **dir, } if ((*dir)[member_ord-1].size > 0) { - uchar buffer[BUFFERSIZE]; + uchar buffer[BUFFERSIZE] = {0}; size_t bytes_read; fseek(archive, (*dir)[member_ord-1].pos, SEEK_SET); do { @@ -139,7 +139,7 @@ void update_archive(char *archive_path, int nmemb, char **membv) { } for (int i = 0; i < nmemb; i++) { - char std_name[MAX_FNAME_LEN]; + char std_name[MAX_FNAME_LEN] = {0}; standardize_name(membv[i], std_name); size_t member_ord = get_ord(dir, dirnmemb, std_name); if (member_ord == 0) { diff --git a/vinapp/src/remove.c b/vinapp/src/remove.c index 4a082cf..8d2d885 100644 --- a/vinapp/src/remove.c +++ b/vinapp/src/remove.c @@ -7,6 +7,10 @@ static void remove_trunc(FILE *archive, struct File_info **dir, size_t *dirnmemb, char *member_name) { + size_t memb_name_size = strnlen(member_name, MAX_FNAME_LEN); + if (member_name[memb_name_size - 1] == '/') + member_name[memb_name_size - 1] = '\0'; + char std_name[MAX_FNAME_LEN] = {0}; standardize_name(member_name, std_name); size_t member_ord = get_ord(*dir, *dirnmemb, std_name);