提交 b371d037 编写于 作者: D Daniel Veillard

* src/internal.h src/xend_internal.c src/xml.c: applied 2 bug fixes

  from Shigeki Sakamoto about large buffers.
Daniel
上级 e826f736
Mon Apr 23 09:38:16 CEST 2007 Daniel Veillard <veillard@redhat.com>
* src/internal.h src/xend_internal.c src/xml.c: applied 2 bug fixes
from Shigeki Sakamoto about large buffers.
Thu Apr 19 12:09:15 IST 2007 Mark McLoughlin <markmc@redhat.com> Thu Apr 19 12:09:15 IST 2007 Mark McLoughlin <markmc@redhat.com>
* docs/libvirt.rng: fix duplicate x86_64 arch * docs/libvirt.rng: fix duplicate x86_64 arch
......
...@@ -105,6 +105,11 @@ extern "C" { ...@@ -105,6 +105,11 @@ extern "C" {
*/ */
#define VIR_CONNECT_RO 1 #define VIR_CONNECT_RO 1
/**
* buffer size for definition file
*/
#define VIR_XML_STRING_BUFLEN (1024 + PATH_MAX * 16 + FILENAME_MAX * 16)
/** /**
* _virConnect: * _virConnect:
* *
......
...@@ -587,7 +587,7 @@ static int ...@@ -587,7 +587,7 @@ static int
xend_op_ext2(virConnectPtr xend, const char *path, char *error, xend_op_ext2(virConnectPtr xend, const char *path, char *error,
size_t n_error, const char *key, va_list ap) size_t n_error, const char *key, va_list ap)
{ {
char ops[1024]; char ops[VIR_XML_STRING_BUFLEN];
const char *k = key, *v; const char *k = key, *v;
int offset = 0; int offset = 0;
......
...@@ -1165,7 +1165,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int ...@@ -1165,7 +1165,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
{ {
xmlDocPtr xml = NULL; xmlDocPtr xml = NULL;
xmlNodePtr node; xmlNodePtr node;
char *ret = NULL, *nam = NULL; char *nam = NULL;
virBuffer buf; virBuffer buf;
xmlChar *prop; xmlChar *prop;
xmlParserCtxtPtr pctxt; xmlParserCtxtPtr pctxt;
...@@ -1182,10 +1182,9 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int ...@@ -1182,10 +1182,9 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
if (name != NULL) if (name != NULL)
*name = NULL; *name = NULL;
ret = malloc(1000); buf.content = malloc(1000);
if (ret == NULL) if (buf.content == NULL)
return (NULL); return (NULL);
buf.content = ret;
buf.size = 1000; buf.size = 1000;
buf.use = 0; buf.use = 0;
...@@ -1376,7 +1375,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int ...@@ -1376,7 +1375,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
else else
free(nam); free(nam);
return (ret); return (buf.content);
error: error:
if (nam != NULL) if (nam != NULL)
...@@ -1389,8 +1388,8 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int ...@@ -1389,8 +1388,8 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
xmlFreeDoc(xml); xmlFreeDoc(xml);
if (pctxt != NULL) if (pctxt != NULL)
xmlFreeParserCtxt(pctxt); xmlFreeParserCtxt(pctxt);
if (ret != NULL) if (buf.content != NULL)
free(ret); free(buf.content);
return (NULL); return (NULL);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册