Commit 2b0f8799 authored by Daniel Veillard's avatar Daniel Veillard

fixed a nasty bug with interning some text strings prepare for beta5 of

* SAX2.c: fixed a nasty bug with interning some text strings
* configure.in: prepare for beta5 of 2.6.0
* libxml.h nanoftp.c nanohttp.c xmlIO.c include/libxml/xmlerror.h:
  better error handling for I/O and converted FTP and HTTP
* parser.c: fixed another bug
Daniel
parent ffbbed42
Fri Oct 10 21:34:01 CEST 2003 Daniel Veillard <daniel@veillard.com>
* SAX2.c: fixed a nasty bug with interning some text strings
* configure.in: prepare for beta5 of 2.6.0
* libxml.h nanoftp.c nanohttp.c xmlIO.c include/libxml/xmlerror.h:
better error handling for I/O and converted FTP and HTTP
* parser.c: fixed another bug
Fri Oct 10 16:45:20 CEST 2003 Daniel Veillard <daniel@veillard.com>
* SAX2.c: fixed uninitialized new field.
......
......@@ -2221,6 +2221,10 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
* We try to minimaze realloc() uses and avoid copying
* and recomputing length over and over.
*/
if ((ctxt->nodemem == ctxt->nodelen + 1) &&
(xmlDictOwns(ctxt->dict, lastChild->content))) {
lastChild->content = xmlStrdup(lastChild->content);
}
if (ctxt->nodelen + len >= ctxt->nodemem) {
xmlChar *newbuf;
int size;
......
......@@ -7,7 +7,7 @@ AC_CANONICAL_HOST
LIBXML_MAJOR_VERSION=2
LIBXML_MINOR_VERSION=6
LIBXML_MICRO_VERSION=0
LIBXML_MICRO_VERSION_SUFFIX=beta4
LIBXML_MICRO_VERSION_SUFFIX=beta5
LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION$LIBXML_MICRO_VERSION_SUFFIX
LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
......
......@@ -34,6 +34,8 @@ typedef enum {
XML_FROM_MEMORY, /* The memory allocator */
XML_FROM_OUTPUT, /* The serialization code */
XML_FROM_IO, /* The Input/Output stack */
XML_FROM_FTP, /* The FTP module */
XML_FROM_HTTP, /* The FTP module */
XML_FROM_XINCLUDE, /* The XInclude processing */
XML_FROM_XPATH, /* The XPath module */
XML_FROM_XPOINTER, /* The XPointer module */
......@@ -426,6 +428,13 @@ typedef enum {
XML_IO_NO_INPUT, /* 1547 */
XML_IO_BUFFER_FULL, /* 1548 */
XML_IO_LOAD_ERROR, /* 1549 */
XML_IO_ENOTSOCK, /* 1550 */
XML_IO_EISCONN, /* 1551 */
XML_IO_ECONNREFUSED, /* 1552 */
XML_IO_ENETUNREACH, /* 1553 */
XML_IO_EADDRINUSE, /* 1554 */
XML_IO_EALREADY, /* 1555 */
XML_IO_EAFNOSUPPORT, /* 1556 */
XML_XINCLUDE_RECURSION=1600,
XML_XINCLUDE_PARSE_VALUE, /* 1601 */
XML_XINCLUDE_ENTITY_DEF_MISMATCH, /* 1602 */
......@@ -545,7 +554,13 @@ typedef enum {
XML_C14N_CREATE_CTXT = 1950,
XML_C14N_REQUIRES_UTF8, /* 1951 */
XML_C14N_CREATE_STACK, /* 1952 */
XML_C14N_INVALID_NODE /* 1953 */
XML_C14N_INVALID_NODE, /* 1953 */
XML_FTP_PASV_ANSWER = 2000,
XML_FTP_EPSV_ANSWER, /* 2001 */
XML_FTP_ACCNT, /* 2002 */
XML_HTTP_URL_SYNTAX = 2020,
XML_HTTP_USE_IP, /* 2021 */
XML_HTTP_UNKNOWN_HOST /* 2022 */
} xmlParserErrors;
/**
......
......@@ -44,4 +44,5 @@
* function while checking if the callback exists.
*/
extern int __xmlRegisterCallbacks;
void __xmlIOErr(int domain, int code, const char *extra);
#endif /* ! __XML_LIBXML_H__ */
This diff is collapsed.
......@@ -159,6 +159,18 @@ static unsigned int timeout = 60;/* the select() timeout in seconds */
int xmlNanoHTTPFetchContent( void * ctx, char ** ptr, int * len );
int xmlNanoHTTPContentLength( void * ctx );
/**
* xmlHTTPErrMemory:
* @extra: extra informations
*
* Handle an out of memory condition
*/
static void
xmlHTTPErrMemory(const char *extra)
{
__xmlSimpleError(XML_FROM_HTTP, XML_ERR_NO_MEMORY, NULL, NULL, extra);
}
/**
* A portability function
*/
......@@ -290,8 +302,8 @@ xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) {
while (1) {
if ((strchr (cur, '[') && !strchr (cur, ']')) ||
(!strchr (cur, '[') && strchr (cur, ']'))) {
xmlGenericError (xmlGenericErrorContext, "\nxmlNanoHTTPScanURL: %s",
"Syntax Error\n");
__xmlIOErr(XML_FROM_HTTP, XML_HTTP_URL_SYNTAX,
"Syntax Error\n");
return;
}
......@@ -301,7 +313,7 @@ xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) {
buf[indx++] = *cur++;
if (!strchr (buf, ':')) {
xmlGenericError (xmlGenericErrorContext, "\nxmlNanoHTTPScanURL: %s",
__xmlIOErr(XML_FROM_HTTP, XML_HTTP_USE_IP,
"Use [IPv6]/IPv4 format\n");
return;
}
......@@ -410,8 +422,7 @@ xmlNanoHTTPScanProxy(const char *URL) {
while (1) {
if ((strchr (cur, '[') && !strchr (cur, ']')) ||
(!strchr (cur, '[') && strchr (cur, ']'))) {
xmlGenericError (xmlGenericErrorContext, "\nxmlNanoHTTPScanProxy: %s",
"Syntax error\n");
__xmlIOErr(XML_FROM_HTTP, XML_HTTP_URL_SYNTAX, "Syntax Error\n");
return;
}
......@@ -421,7 +432,7 @@ xmlNanoHTTPScanProxy(const char *URL) {
buf[indx++] = *cur++;
if (!strchr (buf, ':')) {
xmlGenericError (xmlGenericErrorContext, "\nxmlNanoHTTPScanProxy: %s",
__xmlIOErr(XML_FROM_HTTP, XML_HTTP_USE_IP,
"Use [IPv6]/IPv4 format\n");
return;
}
......@@ -485,7 +496,10 @@ xmlNanoHTTPNewCtxt(const char *URL) {
xmlNanoHTTPCtxtPtr ret;
ret = (xmlNanoHTTPCtxtPtr) xmlMalloc(sizeof(xmlNanoHTTPCtxt));
if (ret == NULL) return(NULL);
if (ret == NULL) {
xmlHTTPErrMemory("allocating context");
return(NULL);
}
memset(ret, 0, sizeof(xmlNanoHTTPCtxt));
ret->port = 80;
......@@ -546,10 +560,7 @@ xmlNanoHTTPSend(xmlNanoHTTPCtxtPtr ctxt, const char * xmt_ptr, int outlen) {
( socket_errno( ) != EAGAIN ) &&
#endif
( socket_errno( ) != EWOULDBLOCK ) ) {
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPSend error: %s",
strerror( socket_errno( ) ) );
__xmlIOErr(XML_FROM_HTTP, 0, "send failed\n");
if ( total_sent == 0 )
total_sent = -1;
break;
......@@ -597,9 +608,8 @@ xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt) {
if (ctxt->in == NULL) {
ctxt->in = (char *) xmlMallocAtomic(65000 * sizeof(char));
if (ctxt->in == NULL) {
xmlHTTPErrMemory("allocating input");
ctxt->last = -1;
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPRecv: Error allocating input memory." );
return(-1);
}
ctxt->inlen = 65000;
......@@ -623,10 +633,7 @@ xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt) {
ctxt->inlen *= 2;
ctxt->in = (char *) xmlRealloc(tmp_ptr, ctxt->inlen);
if (ctxt->in == NULL) {
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPRecv: %s %d bytes.",
"Failed to realloc input buffer to",
ctxt->inlen );
xmlHTTPErrMemory("allocating input buffer");
xmlFree( tmp_ptr );
ctxt->last = -1;
return(-1);
......@@ -657,9 +664,7 @@ xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt) {
return ( 0 );
default:
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPRecv: recv( ) failure - %s",
strerror( socket_errno( ) ) );
__xmlIOErr(XML_FROM_HTTP, 0, "recv failed\n");
return(-1);
}
}
......@@ -843,10 +848,7 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
#ifdef DEBUG_HTTP
perror("socket");
#endif
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPConnectAttempt: %s - %s",
"socket creation failure",
strerror( socket_errno( ) ) );
__xmlIOErr(XML_FROM_HTTP, 0, "socket failed\n");
return(-1);
}
......@@ -877,10 +879,7 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
#ifdef DEBUG_HTTP
perror("nonblocking");
#endif
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPConnectAttempt: %s - %s",
"error setting non-blocking IO",
strerror( socket_errno( ) ) );
__xmlIOErr(XML_FROM_HTTP, 0, "error setting non-blocking IO\n");
closesocket(s);
return(-1);
}
......@@ -893,10 +892,7 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
case EWOULDBLOCK:
break;
default:
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPConnectAttempt: %s - %s",
"error connecting to HTTP server",
strerror( socket_errno( ) ) );
__xmlIOErr(XML_FROM_HTTP, 0, "error connecting to HTTP server");
closesocket(s);
return(-1);
}
......@@ -912,17 +908,12 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
{
case 0:
/* Time out */
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPConnectAttempt: %s",
"Connect attempt timed out." );
__xmlIOErr(XML_FROM_HTTP, 0, "Connect attempt timed out");
closesocket(s);
return(-1);
case -1:
/* Ermm.. ?? */
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPConnectAttempt: %s - %s",
"Error connecting to host",
strerror( socket_errno( ) ) );
__xmlIOErr(XML_FROM_HTTP, 0, "Connect failed");
closesocket(s);
return(-1);
}
......@@ -933,27 +924,19 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
#ifdef SO_ERROR
if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char*)&status, &len) < 0 ) {
/* Solaris error code */
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPConnectAttempt: %s - %s",
"Error retrieving pending socket errors",
strerror( socket_errno( ) ) );
__xmlIOErr(XML_FROM_HTTP, 0, "getsockopt failed\n");
return (-1);
}
#endif
if ( status ) {
__xmlIOErr(XML_FROM_HTTP, 0, "Error connecting to remote host");
closesocket(s);
errno = status;
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPConnectAttempt: %s - %s",
"Error connecting to remote host",
strerror( status ) );
return (-1);
}
} else {
/* pbm */
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPConnectAttempt: %s\n",
"Select returned, but descriptor not set for connection.\n" );
__xmlIOErr(XML_FROM_HTTP, 0, "select failed\n");
closesocket(s);
return (-1);
}
......@@ -1008,10 +991,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
status = getaddrinfo (host, NULL, &hints, &result);
if (status) {
xmlGenericError (xmlGenericErrorContext,
"xmlNanoHTTPConnectHost: %s '%s' - %s",
"Failed to resolve host", host, gai_strerror (status));
__xmlIOErr(XML_FROM_HTTP, 0, "getaddrinfo failed\n");
return (-1);
}
......@@ -1077,13 +1057,9 @@ xmlNanoHTTPConnectHost(const char *host, int port)
h_err_txt = "No error text defined.";
break;
}
xmlGenericError (xmlGenericErrorContext,
"xmlNanoHTTPConnectHost: %s '%s' - %s",
"Failed to resolve host", host, h_err_txt);
__xmlIOErr(XML_FROM_HTTP, 0, h_err_txt);
#else
xmlGenericError (xmlGenericErrorContext,
"xmlNanoHTTPConnectHost: %s '%s'",
"Failed to resolve host", host);
__xmlIOErr(XML_FROM_HTTP, 0, "Failed to resolve host");
#endif
return (-1);
}
......@@ -1252,27 +1228,18 @@ retry:
}
if ( ctxt == NULL ) {
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPMethodRedir: %s %s.",
"Unable to allocate HTTP context to URI",
( ( redirURL == NULL ) ? URL : redirURL ) );
return ( NULL );
}
if ((ctxt->protocol == NULL) || (strcmp(ctxt->protocol, "http"))) {
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPMethodRedir: %s - %s.",
"Not a valid HTTP URI",
( ( redirURL == NULL ) ? URL : redirURL ) );
__xmlIOErr(XML_FROM_HTTP, XML_HTTP_URL_SYNTAX, "Not a valid HTTP URI");
xmlNanoHTTPFreeCtxt(ctxt);
if (redirURL != NULL) xmlFree(redirURL);
return(NULL);
}
if (ctxt->hostname == NULL) {
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPMethodRedir: %s - %s",
"Failed to identify host in URI",
( ( redirURL == NULL ) ? URL : redirURL ) );
__xmlIOErr(XML_FROM_HTTP, XML_HTTP_UNKNOWN_HOST,
"Failed to identify host in URI");
xmlNanoHTTPFreeCtxt(ctxt);
if (redirURL != NULL) xmlFree(redirURL);
return(NULL);
......@@ -1305,9 +1272,7 @@ retry:
bp = xmlMallocAtomic(blen);
if ( bp == NULL ) {
xmlNanoHTTPFreeCtxt( ctxt );
xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPMethodRedir: %s",
"Error allocating HTTP header buffer." );
xmlHTTPErrMemory("allocating header buffer");
return ( NULL );
}
......
......@@ -8271,8 +8271,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
xmlParseContent(ctxt);
if (!IS_BYTE_CHAR(RAW)) {
xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
"Premature end of data in tag %s line %d\n"
"Couldn't find end of Start Tag %s line %d\n",
"Premature end of data in tag %s line %d\n",
name, line, NULL);
/*
......
......@@ -173,8 +173,20 @@ static const char *IOerr[] = {
"No such process", /* ESRCH */
"Operation timed out", /* ETIMEDOUT */
"Improper link", /* EXDEV */
"Attempt to load network entity %s" /* XML_IO_NETWORK_ATTEMPT */
"Attempt to load network entity %s", /* XML_IO_NETWORK_ATTEMPT */
"encoder error", /* XML_IO_ENCODER */
"flush error",
"write error",
"no input",
"buffer full",
"loading error",
"not a socket", /* ENOTSOCK */
"already connected", /* EISCONN */
"connection refuxed", /* ECONNREFUSED */
"unreachable network", /* ENETUNREACH */
"adddress in use", /* EADDRINUSE */
"already in use", /* EALREADY */
"unknown address familly", /* EAFNOSUPPORT */
};
/**
......@@ -190,14 +202,15 @@ xmlIOErrMemory(const char *extra)
}
/**
* xmlIOErr:
* __xmlIOErr:
* @code: the error number
* @
* @extra: extra informations
*
* Handle an I/O error
*/
static void
xmlIOErr(int code, const char *extra)
void
__xmlIOErr(int domain, int code, const char *extra)
{
unsigned int idx;
......@@ -329,6 +342,33 @@ xmlIOErr(int code, const char *extra)
#endif
#ifdef EXDEV
else if (errno == EXDEV) code = XML_IO_EXDEV;
#endif
#ifdef ENOTSOCK
else if (errno == ENOTSOCK) code = XML_IO_ENOTSOCK;
#endif
#ifdef EISCONN
else if (errno == EISCONN) code = XML_IO_EISCONN;
#endif
#ifdef ECONNREFUSED
else if (errno == ECONNREFUSED) code = XML_IO_ECONNREFUSED;
#endif
#ifdef ETIMEDOUT
else if (errno == ETIMEDOUT) code = XML_IO_ETIMEDOUT;
#endif
#ifdef ENETUNREACH
else if (errno == ENETUNREACH) code = XML_IO_ENETUNREACH;
#endif
#ifdef EADDRINUSE
else if (errno == EADDRINUSE) code = XML_IO_EADDRINUSE;
#endif
#ifdef EINPROGRESS
else if (errno == EINPROGRESS) code = XML_IO_EINPROGRESS;
#endif
#ifdef EALREADY
else if (errno == EALREADY) code = XML_IO_EALREADY;
#endif
#ifdef EAFNOSUPPORT
else if (errno == EAFNOSUPPORT) code = XML_IO_EAFNOSUPPORT;
#endif
else code = XML_IO_UNKNOWN;
#endif /* HAVE_ERRNO_H */
......@@ -337,7 +377,20 @@ xmlIOErr(int code, const char *extra)
if (code >= XML_IO_UNKNOWN) idx = code - XML_IO_UNKNOWN;
if (idx >= (sizeof(IOerr) / sizeof(IOerr[0]))) idx = 0;
__xmlSimpleError(XML_FROM_IO, code, NULL, IOerr[idx], extra);
__xmlSimpleError(domain, code, NULL, IOerr[idx], extra);
}
/**
* xmlIOErr:
* @code: the error number
* @extra: extra informations
*
* Handle an I/O error
*/
static void
xmlIOErr(int code, const char *extra)
{
__xmlIOErr(XML_FROM_IO, code, extra);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment