1
0
Fork 0

fix a case where a single-element root path (e.g. /printer) would not pass xmlNodeGetPath

This commit is contained in:
ehofman 2009-04-20 19:56:09 +00:00 committed by Tim Moore
parent 2fc7f94154
commit 8d85732a7d
2 changed files with 20 additions and 24 deletions

View file

@ -1,4 +1,6 @@
20-04-2008
* fix a case where a single-element root path (e.g. "/printer") would not
pass xmlNodeGetPath
* fix a problem where attributes or elements starting with the same letter
sequence could give a false negative result
* Add a 'clear' attribute to the xmlErrorGet functions that indicates whether

View file

@ -44,9 +44,9 @@ typedef struct
#ifndef NDEBUG
# include <stdio.h>
#endif
#include <fcntl.h>
#include <stdlib.h> /* free, malloc */
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <assert.h>
@ -306,13 +306,10 @@ xmlNodeCopyName(const void *id, char *buf, size_t buflen)
assert(buf != 0);
assert(buflen > 0);
slen = buflen-1;
if (slen > xid->name_len)
{
slen = xid->name_len;
}
else
if (slen >= buflen)
{
slen = buflen-1;
xmlErrorSet(xid, 0, XML_TRUNCATE_RESULT);
}
memcpy(buf, xid->name, slen);
@ -1292,13 +1289,13 @@ __xmlNodeGetPath(const char *start, size_t *len, char **name, size_t *plen)
assert(start != 0);
assert(len != 0);
assert(*len != 0);
assert(name != 0);
assert(*name != 0);
assert(plen != 0);
assert(*plen != 0);
if ((*len == 0) || (*plen == 0) || (*plen > *len))
return 0;
if (*plen > *len) return 0;
node = *name;
if (*node == '/') node++;
@ -1314,11 +1311,9 @@ __xmlNodeGetPath(const char *start, size_t *len, char **name, size_t *plen)
if (!path) plen = slen;
else plen = path++ - node;
if (path)
{
num = 0;
ret = __xmlNodeGet(start, len, &node, &plen, &num);
if (ret)
if (ret && path)
{
plen = slen - (path - *name);
ret = __xmlNodeGetPath(ret, len, &path, &plen);
@ -1329,7 +1324,6 @@ __xmlNodeGetPath(const char *start, size_t *len, char **name, size_t *plen)
*name = node;
}
}
}
return ret;
}
@ -1355,7 +1349,7 @@ __xmlNodeGet(const char *start, size_t *len, char **name, size_t *rlen, size_t *
if (*rlen > *len)
{
*rlen = 0;
*name = start;
*name = (char *)start;
*len = XML_UNEXPECTED_EOF;
return 0;
}