Sun, 21 Jul 2024 23:19:40 +0200
fix dav_set_string_property crash if an unknown namespace prefix was specified
dav/main.c | file | annotate | diff | comparison | revisions | |
libidav/resource.c | file | annotate | diff | comparison | revisions | |
libidav/webdav.h | file | annotate | diff | comparison | revisions |
--- a/dav/main.c Fri May 24 00:27:40 2024 +0200 +++ b/dav/main.c Sun Jul 21 23:19:40 2024 +0200 @@ -1877,7 +1877,9 @@ if(namespace) { dav_set_string_property_ns(res, namespace, property, value); } else { - dav_set_string_property(res, property, value); + if(dav_set_string_property(res, property, value)) { + fprintf(stderr, "%s\n", res->session->errorstr); + } } }
--- a/libidav/resource.c Fri May 24 00:27:40 2024 +0200 +++ b/libidav/resource.c Sun Jul 21 23:19:40 2024 +0200 @@ -606,11 +606,16 @@ return property; } -void dav_set_string_property(DavResource *res, char *name, char *value) { +int dav_set_string_property(DavResource *res, char *name, char *value) { char *pns; char *pname; dav_get_property_namespace_str(res->session->context, name, &pns, &pname); + if(!pns) { + res->session->errorstr = "Property namespace not found"; + return 1; + } dav_set_string_property_ns(res, pns, pname, value); + return 0; } static int add2propertylist(const CxAllocator *a, CxList **list, DavProperty *property) {
--- a/libidav/webdav.h Fri May 24 00:27:40 2024 +0200 +++ b/libidav/webdav.h Sun Jul 21 23:19:40 2024 +0200 @@ -358,7 +358,7 @@ DavXmlNode* dav_get_encrypted_property_ns(DavResource *res, const char *ns, const char *name); char* dav_get_string_property(DavResource *res, char *name); char* dav_get_string_property_ns(DavResource *res, char *ns, char *name); -void dav_set_string_property(DavResource *res, char *name, char *value); +int dav_set_string_property(DavResource *res, char *name, char *value); void dav_set_string_property_ns(DavResource *res, char *ns, char *name, char *value); void dav_set_property(DavResource *res, char *name, DavXmlNode *value); void dav_set_property_ns(DavResource *res, char *ns, char *name, DavXmlNode *value);