X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_xml.c;h=c2213ca2c71fdfd55568772954d42d85f770c852;hb=88a3605446744969abe6f193a7bc20e62d5aa555;hp=3581d98455095b04b0d8c946a672edf72e8d526b;hpb=b7093fd3602ef2c796a1f8a0daded9d6aad0b756;p=palacios.git diff --git a/palacios/src/palacios/vmm_xml.c b/palacios/src/palacios/vmm_xml.c index 3581d98..c2213ca 100644 --- a/palacios/src/palacios/vmm_xml.c +++ b/palacios/src/palacios/vmm_xml.c @@ -67,7 +67,7 @@ static void * tmp_realloc(void * old_ptr, size_t old_size, size_t new_size) { new_buf = V3_Malloc(new_size); if (new_buf == NULL) { - PrintError("Cannot allocate in tmp_realloc in xml\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in tmp_realloc in xml\n"); return NULL; } @@ -98,7 +98,7 @@ static void v3_xml_err(struct v3_xml_root * root, char * xml_str, const char * e vsnprintf(root->err, V3_XML_ERRL, fmt, ap); va_end(ap); - PrintError("XML Error: %s\n", root->err); + PrintError(VM_NONE, VCORE_NONE, "XML Error: %s\n", root->err); // free memory v3_xml_free(&(root->xml)); @@ -305,7 +305,7 @@ static void v3_xml_char_content(struct v3_xml_root * root, char * s, size_t len, tmp = V3_Malloc((l = strlen(xml->txt)) + len); if (!tmp) { - PrintError("Cannot allocate in xml char content\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml char content\n"); return ; } @@ -371,7 +371,7 @@ static struct v3_xml * v3_xml_new(const char * name) { struct v3_xml_root * root = (struct v3_xml_root *)V3_Malloc(sizeof(struct v3_xml_root)); if (!root) { - PrintError("Cannot allocate in xml_new\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml_new\n"); return NULL; } @@ -472,7 +472,7 @@ static struct v3_xml * v3_xml_add_child(struct v3_xml * xml, const char * name, child = (struct v3_xml *)V3_Malloc(sizeof(struct v3_xml)); if (!child) { - PrintError("Cannot allocate in xml_add_child\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml_add_child\n"); return NULL; } @@ -516,6 +516,10 @@ static struct v3_xml * parse_str(char * buf, size_t len) { char ** attr; int attr_idx; + if (!buf) { + return NULL; + } + root->str_ptr = buf; if (len == 0) { @@ -585,7 +589,7 @@ static struct v3_xml * parse_str(char * buf, size_t len) { (2 * sizeof(char *)))); if (!attr) { - PrintError("Cannot reallocate in xml parse string\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml parse string\n"); return NULL; } @@ -594,19 +598,19 @@ static struct v3_xml * parse_str(char * buf, size_t len) { (attr_cnt + 1)); if (!attr[last_idx]) { - PrintError("Cannot reallocate in xml parse string\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml parse string\n"); return NULL; } } else { attr = V3_Malloc(4 * sizeof(char *)); if (!attr) { - PrintError("Cannot allocate in xml parse string\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml parse string\n"); return NULL; } attr[last_idx] = V3_Malloc(2); if (!attr[last_idx]) { - PrintError("Cannot alloocate in xml parse string\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot alloocate in xml parse string\n"); return NULL; } } @@ -774,7 +778,7 @@ struct v3_xml * v3_xml_parse(char * buf) { xml_buf = (char *)V3_Malloc(str_len + 1); if (!xml_buf) { - PrintError("Cannot allocate in xml parse\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml parse\n"); return NULL; } @@ -870,7 +874,7 @@ struct v3_xml * v3_xml_set_attr(struct v3_xml * xml, const char * name, const ch xml->attr = V3_Malloc(4 * sizeof(char *)); if (!xml->attr) { - PrintError("Cannot allocate in xml set attr\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml set attr\n"); return NULL; } @@ -878,7 +882,7 @@ struct v3_xml * v3_xml_set_attr(struct v3_xml * xml, const char * name, const ch xml->attr[1] = strdup(""); if (!xml->attr[1]) { - PrintError("Cannot strdup in xml set attr\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot strdup in xml set attr\n"); return NULL; } @@ -886,7 +890,7 @@ struct v3_xml * v3_xml_set_attr(struct v3_xml * xml, const char * name, const ch xml->attr = tmp_realloc(xml->attr, l * sizeof(char *), (l + 4) * sizeof(char *)); if (!xml->attr) { - PrintError("Cannot reallocate in xml set attr\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml set attr\n"); return NULL; } } @@ -903,7 +907,7 @@ struct v3_xml * v3_xml_set_attr(struct v3_xml * xml, const char * name, const ch if (!xml->attr[l + 3]) { - PrintError("Cannot reallocate in xml set attr\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml set attr\n"); return NULL; } @@ -1111,7 +1115,7 @@ static char *toxml_r(struct v3_xml * xml, char **s, size_t *len, size_t *max, *len += sprintf(*s + *len, "", xml->name); // close tag - while (txt[off] && off < xml->off) off++; // make sure off is within bounds + while (off < xml->off && txt[off]) off++; // make sure off is within bounds return (xml->ordered) ? toxml_r(xml->ordered, s, len, max, off) : ampencode(txt + off, -1, s, len, max, 0); } @@ -1126,7 +1130,7 @@ char * v3_xml_tostr(struct v3_xml * xml) { char *s = V3_Malloc(max); if (!s) { - PrintError("Cannot allocate in xml tostrr\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml tostrr\n"); return NULL; }