1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00
Commit Graph

113 Commits

Author SHA1 Message Date
Elliott Hughes
7c06d99e1f Fix xmlURIEscape memory leaks.
Found by running the fuzz/uri.c fuzzer under asan (internal Android bug
171610679).

Always free `ret` when exiting on failure. I've moved the definition of
NULLCHK down past where ret is always initialized to make it clear that
this is safe.

This patch also fixes the indentation of two of the NULLCHK call sites
to make it more obvious that NULLCHK isn't `if`-like.
2020-11-09 18:17:01 +01:00
Nick Wellnhofer
b46016b870 Allow port numbers up to INT_MAX
Also return an error on overflow.
2020-10-17 18:03:09 +02:00
Nick Wellnhofer
20c60886e4 Fix typos
Resolves #133.
2020-03-08 17:41:53 +01:00
Jared Yanovich
2a350ee9b4 Large batch of typo fixes
Closes #109.
2019-09-30 18:04:38 +02:00
Nick Wellnhofer
f9fce96313 Fix unsigned integer overflow
It's defined behavior but -fsanitize=unsigned-integer-overflow is
useful to discover bugs.
2019-05-20 13:38:22 +02:00
Thomas Holder
a71b98ec9d cleanup: remove some unreachable code 2018-11-29 22:25:35 +01:00
Thomas Holder
b1f87c0e43 Fix building relative URIs
Examples:

testURI --relative --base file:///a file:///b
New correct result: b
Old incorrect result: ../b

testURI --relative --base file:///a file:///
New correct result: ./
Old incorrect result: ../

testURI --relative --base file:///a/b file:///a/
New correct result: ./
Old incorrect result: ../../a/
2018-11-29 22:19:44 +01:00
Nick Wellnhofer
41c0a13fe7 Fix Windows compiler warnings in xmlCanonicPath
The code handling Windows paths assigned some char/xmlChar pointers
without explicit casts. Also remove an unused variable.
2017-10-09 13:46:44 +02:00
Daniel Veillard
3daee3f159 Problem resolving relative URIs
Raised by Matthias Pigulla <mp@webfactory.de>

In a nutshell we had that bug on URI composition after some fixes in
the area of localhost empty shortcuts :

./testURI --base file:///some/where file

Without patch: file:/some/file
With patch: file:///some/file
2017-08-28 21:12:14 +02:00
Nick Wellnhofer
91e5496780 Fix xmlBuildRelativeURI for URIs starting with './'
If the relative URI started with './', the 'pos' index was increased
which also affected indexing into the base path. Aside from producing
wrong results, this could also lead to a heap overread of the base
path buffer. The data read from beyond the buffer was only compared
to some char values, so this is mostly harmless.

Inside libxml2, xmlBuildRelativeURI is only called from xinclude.c.

Found with libFuzzer and ASan.
2017-06-10 17:41:42 +02:00
Nick Wellnhofer
d6b3645f9b Fix memory leak in xmlCanonicPath
Found with libFuzzer and ASan.
2017-05-27 15:59:18 +02:00
Michael Paddon
846cf015a7 Integer overflow parsing port number in URI
For https://bugzilla.gnome.org/show_bug.cgi?id=765566

in xmlParse3986Port(), uri->port can overflow when parsing a the port number.
The type of uri->port is int, so the consequent behavior is undefined and
may differ between compilers and architectures
2016-05-21 17:18:15 +08:00
Daniel Veillard
beb7281055 Fix a problem properly saving URIs
As written by Martin Kletzander <mkletzan@redhat.com>:
Since commit 8eb55d782a, when you parse
and save an URI that has no server (or similar) part, two slashes
after the 'schema:' get lost.  It means 'uri:///noserver' is turned
into 'uri:/noserver'.

basically
   foo:///only/path

means a host of "" while

   foo:/only/path

means no host at all

  So the best fix IMHO is to fix the URI parser to record the first
case and an empty host string and the second case as a NULL host string

 I would not revert the initial patch, we should not 'invent' those
slash, but we should instead when parsing keep the information that
it's a host based path and that foo:/// means the presence of a host
but an empty one.

Once applied the resulting patch below, all cases seems to be saved
properly:

thinkpad:~/XML -> ./testURI uri:/noserver
uri:/noserver
thinkpad:~/XML -> ./testURI uri:///noserver
uri:///noserver
thinkpad:~/XML -> ./testURI uri://server/foo
uri://server/foo
thinkpad:~/XML -> ./testURI uri:/noserver/foo
uri:/noserver/foo
thinkpad:~/XML -> ./testURI uri:///
uri:///
thinkpad:~/XML -> ./testURI uri://
uri://
thinkpad:~/XML -> ./testURI uri:/
uri:/
thinkpad:~/XML ->

  If you revert the initial patch that last case fails

The problem is that I don't want to change the xmlURI structure to
minimize ABI breakage, so I could not extend the field. The natural
solution is to denote that uri:/// has an empty host by making
the uri server field an empty string which works very well but breaks
applications (like libvirt ;-) who blindly look at uri->server
not being NULL to try to reach it !
Simplest was to stick the port to -1 in that case, instead of 0
application don't bother looking at the port of there is no server
string, this makes the patch more complex than a 1 liner, but
is better for ABI.
2014-10-03 19:22:39 +08:00
Dennis Filder
8eb55d782a xmlSaveUri() incorrectly recomposes URIs with rootless paths
For https://bugzilla.gnome.org/show_bug.cgi?id=731063

xmlSaveUri() of libxml2 (snapshot 2014-05-31 and earlier) returns
bogus values when called with URIs that have rootless paths
(e.g. "urx🅱️b" becomes "urx://b%3Ab" where "urx:b%3Ab" would be
correct)
2014-06-13 14:56:14 +08:00
Michael Stahl
55b899a23a Support long path names on WNT
so we've got this patch to libxml2 2.7.6 in the LibreOffice code base,
inherited from OOo.  it fixes a definite problem, which is that Windows
has a rather low maximum path length restriction, and there is a special
trick on NT whereby path names can be prefixed with "\\?\", in which
case the maximum length is 32k, which ought to be sufficient even for
bloated office suites :)

I'll attach the patch to the xmlCanonicPath function.  note that i
didn't write this and am by no means an expert on either Microsoftean
platforms or libxml so maybe it's not the best way to do it.
2012-09-07 12:19:25 +08:00
Daniel Veillard
5756038650 Cleanup URI module memory allocation code
* uri.c: cleanup the code doing the allocations, set up a structured
  error handler to report memory errors, and set up an abitrary
  limit on URI saving size
* error.c include/libxml/xmlerror.h: add a new FROM_URI indication
  for structured error reporting, also adding strings for schematron
  and buffer which were missing
2012-07-24 11:44:23 +08:00
Daniel Veillard
fc74a6f5c2 URI handling code is not OOM resilient
as pointed out by Dan Berrange, add a small comment in the header
2012-05-07 15:02:25 +08:00
Nico Weber
cedf84d35a Fix -Wempty-body warning from clang
clang recently grew a warning on `for (...);`. This patch
fixes all two instances of this pattern in libxml. The changes
don't modify the code semantic.
2012-03-05 16:36:59 +08:00
Daniel Veillard
2ee91eb658 Fix handling of apos in URIs
François Delyon <f.delyon@satimage.fr> pointed out a divergence between
the URI code and RFC 3986, fix trivial and seems to not break regression
tests
2010-06-04 09:14:16 +08:00
Daniel Veillard
1358fef9aa URI with no path parsing problem
* uri.c: Ralf Junker pointed out that URI with no path
  like http://www.domain.com when parsed ended up with an
  empty path value instead of NULL, this fixes the problem
2009-10-02 17:29:48 +02:00
Daniel Veillard
13cee4e37b Fix a bunch of scan 'dead increments' and cleanup
* HTMLparser.c c14n.c debugXML.c entities.c nanohttp.c parser.c
  testC14N.c uri.c xmlcatalog.c xmllint.c xmlregexp.c xpath.c:
  fix unused variables, or unneeded increments as well as a couple
  of space issues
* runtest.c: check for NULL before calling unlink()
2009-09-05 14:52:55 +02:00
Daniel Veillard
f582d14fbc bug in parsing RFC 3986 uris with port numbers Daniel
* uri.c: bug in parsing RFC 3986 uris with port numbers
Daniel

svn path=/trunk/; revision=3781
2008-08-27 17:23:41 +00:00
Daniel Veillard
84c45df8d8 allow [ and ] in fragment identifiers, 3986 disallow them but it's widely
* uri.c: allow [ and ] in fragment identifiers, 3986 disallow them
  but it's widely used for XPointer, and would break DocBook
  processing among others
Daniel

svn path=/trunk/; revision=3765
2008-08-06 10:26:06 +00:00
Daniel Veillard
d7af555327 rewrite the URI parser to update to rfc3986 (from 2396) removed the error
* uri.c include/libxml/uri.h: rewrite the URI parser to update to
  rfc3986 (from 2396)
* test/errors/webdav.xml result/errors/webdav.xml*: removed the
  error test, 'DAV:' is a correct URI under 3986
* Makefile.am: small cleanup in make check
Daniel

svn path=/trunk/; revision=3763
2008-08-04 15:29:44 +00:00
Daniel Veillard
ed86dc2383 applied patch from Ashwin fixing a number of realloc problems improve
* uri.c: applied patch from Ashwin fixing a number of realloc problems
* HTMLparser.c: improve handling for misplaced html/head/body
Daniel

svn path=/trunk/; revision=3740
2008-04-24 11:58:41 +00:00
Daniel Veillard
e54c3173b8 fix saving for file:///X:/ URI embedding Windows file paths should fix
* uri.c: fix saving for file:///X:/ URI embedding Windows file paths
  should fix #524253 
Daniel

svn path=/trunk/; revision=3714
2008-03-25 13:22:41 +00:00
Daniel Veillard
69f8a13e52 applied a patch based on Petr Sumbera one to avoid a problem with paths
* uri.c: applied a patch based on Petr Sumbera one to avoid a 
  problem with paths starting with //
Daniel

svn path=/trunk/; revision=3683
2008-02-05 08:37:56 +00:00
William M. Brack
504201966d applied patch from from Patrik Fimml. Fixes bug #458268
* uri.c: applied patch from from Patrik Fimml.  Fixes bug #458268

svn path=/trunk/; revision=3645
2007-07-20 01:09:08 +00:00
Daniel Veillard
e61d75f11e fix bug reported by François Delyon Daniel
* uri.c: fix bug reported by François Delyon
Daniel

svn path=/trunk/; revision=3619
2007-05-28 14:16:33 +00:00
Daniel Veillard
a1413b84f7 patch from Richard Jones to save the query part in raw form. Daniel
* uri.c include/libxml/uri.h: patch from Richard Jones to save
  the query part in raw form.
Daniel

svn path=/trunk/; revision=3607
2007-04-26 08:33:28 +00:00
Daniel Veillard
7918765454 More doc cleanup, Daniel
svn path=/trunk/; revision=3604
2007-04-24 10:19:52 +00:00
Daniel Veillard
a44294f10b fix xmlURIUnescapeString comments which was confusing Daniel
* uri.c: fix xmlURIUnescapeString comments which was confusing
Daniel

svn path=/trunk/; revision=3603
2007-04-24 08:57:54 +00:00
William M. Brack
2224227818 implemented patch from S. Bidoul for uri.c (bug #389767)
* implemented patch from S. Bidoul for uri.c (bug #389767)

svn path=/trunk/; revision=3576
2007-01-27 07:59:37 +00:00
Daniel Veillard
481dcfcff3 applied patch from Igor for path conversion on Windows Daniel
* uri.c: applied patch from Igor for path conversion on Windows
Daniel
2006-11-06 08:54:18 +00:00
Daniel Veillard
b8efdda0a3 add a new function xmlPathToUri() to provide a clean conversion when
* uri.c include/libxml/uri.h: add a new function xmlPathToUri()
  to provide a clean conversion when setting up a base
* SAX2.c tree.c: use said function when setting up doc->URL
  or using the xmlSetBase function. Should fix #346261
Daniel
2006-10-10 12:37:14 +00:00
Daniel Veillard
30e7607b7a a bunch of small cleanups based on coverity reports. Daniel
* HTMLparser.c parser.c parserInternals.c pattern.c uri.c: a bunch
  of small cleanups based on coverity reports.
Daniel
2006-03-09 14:13:55 +00:00
Daniel Veillard
8f3392ef69 applied patch from Rob Richards fixing the URI regressions tests on
* uri.c: applied patch from Rob Richards fixing the URI regressions
  tests on Windows which seems to indicate bad escaping.
Daniel
2006-02-03 09:45:10 +00:00
Daniel Veillard
0f7b33101b more fixes to the behaviour of xmlBuildRelativeURI Daniel
* uri.c: more fixes to the behaviour of xmlBuildRelativeURI
Daniel
2005-09-15 14:15:20 +00:00
William M. Brack
820d5ed747 fixed problem when xmlBuildRelativeURI was given a blank path (bug 316224)
* uri.c: fixed problem when xmlBuildRelativeURI was given a
  blank path (bug 316224)
2005-09-14 05:24:27 +00:00
Daniel Veillard
336a8e13bf get rid of the dependancy on a locally installed DTD try to cleanup the
* test/relaxng/docbook_0.xml: get rid of the dependancy on a locally
  installed DTD
* uri.c include/libxml/uri.h xmlIO.c nanoftp.c nanohttp.c: try to
  cleanup the Path/URI conversion mess, needed fixing in various
  layers and a new API to the uri module which also fixes #306861
* runtest.c: integrated a regression test specific to check the
  URI conversions done before calling the I/O handlers.
Daniel
2005-08-07 10:46:19 +00:00
William M. Brack
38c4b332c4 enhanced xmlBuildRelativeURI to allow the URI and the base to be in
* uri.c: enhanced xmlBuildRelativeURI to allow the URI and the
  base to be in "relative" form
2005-07-25 18:39:34 +00:00
Daniel Veillard
5d4644ef6e revamped the elfgcchack.h format to cope with gcc4 change of aliasing
* doc/apibuild.py doc/elfgcchack.xsl: revamped the elfgcchack.h
  format to cope with gcc4 change of aliasing allowed scopes, had
  to add extra informations to doc/libxml2-api.xml to separate
  the header from the c module source.
* *.c: updated all c library files to add a #define bottom_xxx
  and reimport elfgcchack.h thereafter, and a bit of cleanups.
* doc//* testapi.c: regenerated when rebuilding the API
Daniel
2005-04-01 13:11:58 +00:00
William M. Brack
015ccb2c74 This change started out as a simple desire to speed up the
execution time of testapi.c, which was being delayed by
nameserver requests for non-existent URL's.  From there it
just sort of grew, and grew....
* nanohttp.c, nanoftp.c: changed the processing of URL's
  to use the uri.c routines instead of custom code.
* include/libxml/xmlerror.h: added code XML_FTP_URL_SYNTAX
* uri.c: added accepting ipV6 addresses, in accordance with
  RFC's 2732 and 2373 (TODO: allow ipV4 within ipV6)
* gentest.py, testapi.c: fixed a few problems with the
  testing of the nanoftp and nanohttp routines.
* include/libxml/xmlversion.h: minor change to fix a
  warning on the docs generation
* regenerated the docs
2005-02-13 08:18:52 +00:00
William M. Brack
f3cf1a1e18 fixed problem with xmlURIEscape when query part was empty (actually fixed
* uri.c: fixed problem with xmlURIEscape when query part was
  empty (actually fixed xmlURIEscapeStr to return an empty
  string rather than NULL for empty string input) (bug 163079)
2005-01-06 02:25:59 +00:00
William M. Brack
f2a657aa59 fixed a stupid mistake in xmlBuildRelativeURI (bug 156527)
* uri.c: fixed a stupid mistake in xmlBuildRelativeURI
  (bug 156527)
2004-10-27 16:33:09 +00:00
Daniel Veillard
8399ff337e couple of memory fixes from Mark Vakoc reported by Purify on Windows.
* threads.c uri.c: couple of memory fixes from Mark Vakoc reported
  by Purify on Windows.
Daniel
2004-09-22 21:57:53 +00:00
William M. Brack
a3215c7ae6 many further little changes for OOM problems. Now seems to be getting
* SAX2.c, encoding.c, error.c, parser.c, tree.c, uri.c, xmlIO.c,
  xmlreader.c, include/libxml/tree.h: many further little changes
  for OOM problems.  Now seems to be getting closer to "ok".
* testOOM.c: added code to intercept more errors, found more
  problems with library. Changed method of flagging / counting
  errors intercepted.
2004-07-31 16:24:01 +00:00
William M. Brack
42331a9029 further fixes for out of memory condition, mostly from Olivier Andrieu.
* SAX2.c, tree.c, uri.c, xmlIO.c, xmlreader.c: further
  fixes for out of memory condition, mostly from Olivier
  Andrieu.
* testOOM.c: some further improvement by Olivier, with
  a further small enhancement for easier debugging.
2004-07-29 07:07:16 +00:00
Daniel Veillard
be3eb2088e fixed a couple of problems in the new elfgcchack.h trick pointed by Peter
* libxml.h uri.c: fixed a couple of problems in the new
  elfgcchack.h trick pointed by Peter Breitenlohner
Daniel
2004-07-09 12:05:25 +00:00
William M. Brack
f20fbf70b2 fixed a problem when base path was "./xxx" 5 test results changed by
* uri.c: fixed a problem when base path was "./xxx"
* result/XInclude/*: 5 test results changed by above.
* Makefile.am: fixed a couple of spots where a new
  result file used different flags that the testing one.
2004-06-25 05:49:08 +00:00