From 04b2b17e96842aca30ef97ef450e486f446206d3 Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Sat, 13 Nov 2010 14:02:20 +0200 Subject: [PATCH] ladishd: project name unescaping --- daemon/room_load.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/daemon/room_load.c b/daemon/room_load.c index 7cb4572a..3afa2190 100644 --- a/daemon/room_load.c +++ b/daemon/room_load.c @@ -76,6 +76,7 @@ static void callback_elstart(void * data, const char * el, const char ** attr) ladish_port_handle port2; uint32_t port_type; uint32_t port_flags; + size_t len; if (context_ptr->error) { @@ -100,16 +101,19 @@ static void callback_elstart(void * data, const char * el, const char ** attr) return; } - log_info("Project '%s' with uuid %s", name, uuid_str); - - room_ptr->project_name = strdup(name); + len = strlen(name) + 1; + room_ptr->project_name = malloc(len); if (room_ptr->project_name == NULL) { - log_error("strdup() failed for project name"); + log_error("malloc() failed for project name with length %zu", len); context_ptr->error = XML_TRUE; return; } + room_ptr->project_name[unescape(name, len, room_ptr->project_name)] = 0; + + log_info("Project '%s' with uuid %s", room_ptr->project_name, uuid_str); + uuid_copy(room_ptr->project_uuid, uuid); return; @@ -779,16 +783,20 @@ static void project_name_elstart_callback(void * data, const char * el, const ch const char * name; const char * uuid_str; uuid_t uuid; + size_t len; if (strcmp(el, "project") == 0) { if (ladish_get_name_and_uuid_attributes("/project", attr, &name, &uuid_str, uuid)) { - context_ptr->str = strdup(name); + len = strlen(name) + 1; + context_ptr->str = malloc(len); if (context_ptr->str == NULL) { - log_error("strdup() failed for project name"); + log_error("malloc() failed for project name with length %zu", len); } + + context_ptr->str[unescape(name, len, context_ptr->str)] = 0; } XML_StopParser(context_ptr->parser, XML_TRUE);