Changeset 04b2b17e96842aca30ef97ef450e486f446206d3

Show
Ignore:
Timestamp:
11/13/10 14:02:20 (3 years ago)
Author:
Nedko Arnaudov <nedko@…>
Children:
3752081d1de2bd77d8bc7fb35ebfb0919b8de5e6
Parents:
c0240447c1f018bcb69fceaf073a43ed8e304e8a
git-committer:
Nedko Arnaudov <nedko@arnaudov.name> / 2010-11-13T14:02:20Z+0200
Message:

ladishd: project name unescaping

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • daemon/room_load.c

    rbea7c69 r04b2b17  
    7777  uint32_t port_type; 
    7878  uint32_t port_flags; 
     79  size_t len; 
    7980 
    8081  if (context_ptr->error) 
     
    101102    } 
    102103 
    103     log_info("Project '%s' with uuid %s", name, uuid_str); 
    104  
    105     room_ptr->project_name = strdup(name); 
     104    len = strlen(name) + 1; 
     105    room_ptr->project_name = malloc(len); 
    106106    if (room_ptr->project_name == NULL) 
    107107    { 
    108       log_error("strdup() failed for project name"); 
    109       context_ptr->error = XML_TRUE; 
    110       return; 
    111     } 
     108      log_error("malloc() failed for project name with length %zu", len); 
     109      context_ptr->error = XML_TRUE; 
     110      return; 
     111    } 
     112 
     113    room_ptr->project_name[unescape(name, len, room_ptr->project_name)] = 0; 
     114 
     115    log_info("Project '%s' with uuid %s", room_ptr->project_name, uuid_str); 
    112116 
    113117    uuid_copy(room_ptr->project_uuid, uuid); 
     
    780784  const char * uuid_str; 
    781785  uuid_t uuid; 
     786  size_t len; 
    782787 
    783788  if (strcmp(el, "project") == 0) 
     
    785790    if (ladish_get_name_and_uuid_attributes("/project", attr, &name, &uuid_str, uuid)) 
    786791    { 
    787       context_ptr->str = strdup(name); 
     792      len = strlen(name) + 1; 
     793      context_ptr->str = malloc(len); 
    788794      if (context_ptr->str == NULL) 
    789795      { 
    790         log_error("strdup() failed for project name"); 
    791       } 
     796        log_error("malloc() failed for project name with length %zu", len); 
     797      } 
     798 
     799      context_ptr->str[unescape(name, len, context_ptr->str)] = 0; 
    792800    } 
    793801