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

from Shigeki Sakamoto about large buffers.
Daniel
This commit is contained in:
Daniel Veillard 2007-04-23 07:41:23 +00:00
parent e826f73647
commit b371d037b2
4 changed files with 17 additions and 8 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -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:
* *

View File

@ -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;

View File

@ -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
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
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
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);
} }