--- a/dav/tar.c Sun Apr 16 14:12:24 2023 +0200 +++ b/dav/tar.c Fri Apr 21 21:25:32 2023 +0200 @@ -29,7 +29,7 @@ #include "tar.h" #include <string.h> -#include <ucx/string.h> +#include <cx/string.h> #include <libidav/utils.h> @@ -59,13 +59,13 @@ static int add_header(TarOutputStream *tar, char *path, uint32_t mode, uint64_t size, time_t mtime, int type) { // split path in prefix and name and check length char *p = util_parent_path(path); - char *n = util_resource_name(path); + const char *n = util_resource_name(path); if(!p || !n) { return -1; } - sstr_t prefix = sstr(p); - sstr_t name = sstr(n); + cxstring prefix = cx_str(p); + cxstring name = cx_str(n); if(prefix.ptr[prefix.length-1] == '/') { prefix.length--; @@ -73,16 +73,19 @@ if(prefix.length > 154) { tar->error = TAR_PATH_TOO_LONG; + free(p); return -1; } if(name.length > 99) { tar->error = TAR_PATH_TOO_LONG; + free(p); return -1; } // check file length if(size >= 077777777777 ) { tar->error = TAR_FILE_TOO_LARGE; + free(p); return -1; } @@ -136,6 +139,8 @@ fwrite(&h, 1, 512, tar->file); + free(p); + return 0; }