From b371d037b27f0cc64a5761255768744d1352222d Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Mon, 23 Apr 2007 07:41:23 +0000 Subject: [PATCH] * src/internal.h src/xend_internal.c src/xml.c: applied 2 bug fixes from Shigeki Sakamoto about large buffers. Daniel --- ChangeLog | 5 +++++ src/internal.h | 5 +++++ src/xend_internal.c | 2 +- src/xml.c | 13 ++++++------- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ceecf28ae..6b663c50f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Apr 23 09:38:16 CEST 2007 Daniel Veillard + + * 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 * docs/libvirt.rng: fix duplicate x86_64 arch diff --git a/src/internal.h b/src/internal.h index b01dda2b6e..f37199811e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -105,6 +105,11 @@ extern "C" { */ #define VIR_CONNECT_RO 1 +/** + * buffer size for definition file + */ +#define VIR_XML_STRING_BUFLEN (1024 + PATH_MAX * 16 + FILENAME_MAX * 16) + /** * _virConnect: * diff --git a/src/xend_internal.c b/src/xend_internal.c index 7de277d801..fb1cd10e2e 100644 --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -587,7 +587,7 @@ static int xend_op_ext2(virConnectPtr xend, const char *path, char *error, size_t n_error, const char *key, va_list ap) { - char ops[1024]; + char ops[VIR_XML_STRING_BUFLEN]; const char *k = key, *v; int offset = 0; diff --git a/src/xml.c b/src/xml.c index 6796d53ece..a5894a49a7 100644 --- a/src/xml.c +++ b/src/xml.c @@ -1165,7 +1165,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int { xmlDocPtr xml = NULL; xmlNodePtr node; - char *ret = NULL, *nam = NULL; + char *nam = NULL; virBuffer buf; xmlChar *prop; xmlParserCtxtPtr pctxt; @@ -1182,10 +1182,9 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int if (name != NULL) *name = NULL; - ret = malloc(1000); - if (ret == NULL) + buf.content = malloc(1000); + if (buf.content == NULL) return (NULL); - buf.content = ret; buf.size = 1000; buf.use = 0; @@ -1376,7 +1375,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int else free(nam); - return (ret); + return (buf.content); error: if (nam != NULL) @@ -1389,8 +1388,8 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int xmlFreeDoc(xml); if (pctxt != NULL) xmlFreeParserCtxt(pctxt); - if (ret != NULL) - free(ret); + if (buf.content != NULL) + free(buf.content); return (NULL); } -- GitLab