# HG changeset patch # User Olaf Wintermann # Date 1679230959 -3600 # Node ID f69d88f86b9cf83dd123581f56c092c82a5cd1a3 # Parent b02da778362eef703bd162ba340417cc17a47dc9 add error handling to webdav_xattr_serialze_map() diff -r b02da778362e -r f69d88f86b9c src/server/webdav/xattrbackend.c --- a/src/server/webdav/xattrbackend.c Sun Mar 19 11:14:10 2023 +0100 +++ b/src/server/webdav/xattrbackend.c Sun Mar 19 14:02:39 2023 +0100 @@ -673,17 +673,33 @@ property_value = &prop->value.data; } - cx_bprintf(&buf, "prop xmlns:%s=\"%s\" %s\n", prop->namespace->prefix, prop->namespace->href, prop->name); + int ret = cx_bprintf(&buf, "prop xmlns:%s=\"%s\" %s\n", prop->namespace->prefix, prop->namespace->href, prop->name); + if(ret <= 0) { + pool_free(pool, buf.space); + return (cxmutstr){NULL,0}; + } if(property_value) { WebdavNSList *ns = property_value->namespaces; while(ns) { - cx_bprintf(&buf, "ns %s:%s\n", prop->namespace->prefix, prop->namespace->href); + ret = cx_bprintf(&buf, "ns %s:%s\n", prop->namespace->prefix, prop->namespace->href); + if(ret <= 0) { + pool_free(pool, buf.space); + return (cxmutstr){NULL,0}; + } ns = ns->next; } - cx_bprintf(&buf, "data %zu\n", property_value->length); + ret = cx_bprintf(&buf, "data %zu\n", property_value->length); + if(ret <= 0) { + pool_free(pool, buf.space); + return (cxmutstr){NULL,0}; + } + cxBufferWrite(property_value->data, 1, property_value->length, &buf); - cxBufferPut(&buf, '\n'); + if(cxBufferPut(&buf, '\n') < 0) { + pool_free(pool, buf.space); + return (cxmutstr){NULL,0}; + } } }