# HG changeset patch # User Olaf Wintermann # Date 1565893521 -7200 # Node ID 1f76d9624db840e25b581f5e934501ea8b2c7552 # Parent 81e066c9ff87aaa7a2b702eaa39f24db35872ea3 fix url2repo not creating a string dup in case a repo doesn't exist diff -r 81e066c9ff87 -r 1f76d9624db8 dav/main.c --- a/dav/main.c Thu Aug 15 20:00:40 2019 +0200 +++ b/dav/main.c Thu Aug 15 20:25:21 2019 +0200 @@ -384,7 +384,7 @@ *path = strdup("/"); } else if (strchr(url, '/')) { repo->url = util_url_base(url); - *path = util_url_path(url); + *path = strdup(util_url_path(url)); } else { repo->url = strdup(url); *path = strdup("/"); @@ -1555,6 +1555,18 @@ return dav_create(res); } +static void print_cannoterr(DavSession *sn, const char *message) { + switch(sn->error) { + case DAV_UNSUPPORTED_PROTOCOL: + case DAV_COULDNT_RESOLVE_PROXY: + case DAV_COULDNT_RESOLVE_HOST: + case DAV_COULDNT_CONNECT: + case DAV_TIMEOUT: + case DAV_SSL_ERROR: break; + default: fprintf(stderr, "Cannot %s.\n", message); + } +} + static int cmd_operation_on_resources(CmdArgs* a, int(*operation)(DavResource*), const char* command, @@ -1589,7 +1601,7 @@ if(a->argc == 1) { if(operation(res)) { - fprintf(stderr, "Cannot %s.\n", message); + print_cannoterr(sn, message); print_resource_error(sn, res->path); goto cmd_oponres_exit; } @@ -1599,7 +1611,7 @@ assert(!!child); child->iscollection = 1; if(operation(child)) { - fprintf(stderr, "Cannot %s %s.\n", message, a->argv[i]); + print_cannoterr(sn, message); print_resource_error(sn, child->path); goto cmd_oponres_exit; }