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

39 Commits

Author SHA1 Message Date
Daniel Veillard
5fe9e9ed1c Remove risk of lockup in dictionary initialization
Reported by Petr Sumbera <petr.sumbera@oracle.com>
Two threads entering xmlInitializeDict concurently could lead
to a lockup due to multiple initializations of the lock used.
To avoid this problem move this to a new private function
called from xmlOnceInit() and deprecate the old initalizer.
Since threaded programs must call xmlInitParser() and this
will lead to dereference of private data and the call to
xmlOnceInit() guaranteed to be unique this should be safe now.
2013-04-05 23:10:41 +08:00
Wouter Van Rooy
e7715a5963 rand_seed should be static in dict.c
For https://bugzilla.gnome.org/show_bug.cgi?id=683933
rand_seed should be a static variable in dict.c

We ran into a problem with another library that exports rand_seed as a
function. Combined with 2.7.8 this was not a problem but later versions
have this problem.
2012-09-14 14:39:42 +08:00
Patrick Gansterer
fd4f6fddf5 Fix non __GNUC__ build
For https://bugzilla.gnome.org/show_bug.cgi?id=681590
Length member of _xmlDictEntry is called "len" and not "l"
2012-08-13 17:54:20 +08:00
Daniel Veillard
7c693dad23 Cleanups and new limit APIs for dictionaries
* include/libxml/dict.h dict.c: adding 2 new functions xmlDictGetUsage
  and xmlDictSetLimit allowing to review the amount of memory allocated
  for dictionary strings. Aslo cleanup of various signed int used as
  size values in the code.
2012-07-25 16:32:18 +08:00
Daniel Veillard
ee8f1d4cda Cleanups before 2.8.0-rc2
new symbols, a missing comment and a fix on symbol release
2012-05-21 11:16:12 +08:00
Daniel Veillard
379ebc1d77 Cleanup on randomization
tsan reported that rand() is not thread safe, so create
a thread safe wrapper, use rand_r() if available.
Consolidate the function, initialization and cleanup in
dict.c and make sure it is initialized in xmlInitParser()
2012-05-18 15:41:31 +08:00
Rob Richards
aa0be5f269 fix windows build.
ifdef addition from bug 666491 makes no sense
2012-05-09 12:42:51 -04:00
Thomas Lemm
066c697772 Allow to compile with Visual Studio 2010
For https://bugzilla.gnome.org/show_bug.cgi?id=666491

This patch adds project files to compile and debug libxml2 using Visual
Studio 2010. Only few minor changes have been made to the actual source
code.

This patch also requires for the iconv package to be compiled with visual
studio 2010 which has been submitted to the iconv project (see:
https://savannah.gnu.org/bugs/?35088)
2012-05-09 18:27:04 +08:00
Daniel Veillard
8973d58b74 Add hash randomization to hash and dict structures
Following http://www.ocert.org/advisories/ocert-2011-003.html
it seems that having hash randomization might be a good idea
when using XML with untrusted data
* configure.in: lookup for rand, srand and time
* dict.c: add randomization to dictionaries hash tables
* hash.c: add randomization to normal hash tables
2012-02-13 11:11:01 +08:00
Daniel Veillard
594e5dfb48 Chasing dead assignments reported by clang-scan
* SAX2.c dict.c error.c hash.c nanohttp.c parser.c python/libxml.c
  relaxng.c runtest.c tree.c valid.c xinclude.c xmlregexp.c xmlsave.c
  xmlschemas.c xpath.c xpointer.c: mostly removing unneded affectations,
  but this led to a few real bugs and some part not yet understood
  (relaxng/interleave)
2009-09-07 14:58:47 +02:00
Daniel Veillard
7f4547cdbd preparing the release of 2.7.2 fix the Solaris portability issue
* configure.in doc/* NEWS: preparing the release of 2.7.2
* dict.c: fix the Solaris portability issue
* parser.c: additional cleanup on #554660 fix
* test/ent13 result/ent13* result/noent/ent13*: added the
  example in the regression test suite.
* HTMLparser.c: handle leading BOM in htmlParseElement()
Daniel

svn path=/trunk/; revision=3799
2008-10-03 07:58:23 +00:00
Rob Richards
117baa074d fix non GNUC builds.
* dict.c: fix non GNUC builds.

svn path=/trunk/; revision=3771
2008-08-10 17:07:33 +00:00
Daniel Veillard
d68f8912c4 added a program to regression test the dictionary code improve the lookup
* testdict.c: added a program to regression test the dictionary code
* dict.c: improve the lookup efficiency by caching the key.
Daniel

svn path=/trunk/; revision=3768
2008-08-08 10:09:19 +00:00
Daniel Veillard
ffda65f0e6 chased and found a couple of nasty issues Daniel
* dict.c: chased and found a couple of nasty issues
Daniel

svn path=/trunk/; revision=3767
2008-08-07 16:33:49 +00:00
Daniel Veillard
424785e793 change the big key algorithm to work properly with QName too, fix a bug
* dict.c: change the big key algorithm to work properly with QName
  too, fix a bug with dict size and sub dictionaries
Daniel

svn path=/trunk/; revision=3764
2008-08-06 09:35:25 +00:00
Rob Richards
b6b2ee1a40 check for stdint.h and define types when using MSVC
* dict.c: check for stdint.h and define types when using MSVC

svn path=/trunk/; revision=3742
2008-05-03 12:34:25 +00:00
Daniel Veillard
e9100a589d improvement on the hashing of the dictionnary, with visible speed up as
* dict.c: improvement on the hashing of the dictionnary, with visible
  speed up as the number of strings in the hash increases, work from
  Stefan Behnel
Daniel

svn path=/trunk/; revision=3739
2008-04-22 08:28:50 +00:00
Daniel Veillard
b242b08831 applied patch from Florent Guilian to remove an useless mutex in the
* dict.c: applied patch from Florent Guilian to remove an
  useless mutex in the xmlDict structure.

older, not commited ...

* SAX2.c: another leak reported by Ashwin
* xinclude.c: fixed the behaviour when XIncluding a fragment
  of the current document, patch from Chris Ryan

Daniel


svn path=/trunk/; revision=3686
2008-02-08 09:56:31 +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
4e1c2db89e fixed compilation warning changed xmlWarningMsg so ctxt->errNo is not set
* dict.c: fixed compilation warning
* parser.c: changed xmlWarningMsg so ctxt->errNo is not set
* xmllint.c: changed to return non-zero status if error
  on xinclude processing
* xmlsave.c: minor deletion of a redundant condition statement
2005-02-11 10:58:55 +00:00
Daniel Veillard
2ae13382c3 fixing the way testapi.c is generated, fixes bug #161386 fix a comment
* Makefile.am testapi.c doc/Makefile.am: fixing the way testapi.c
  is generated, fixes bug #161386
* dict.c: fix a comment typo
* elfgcchack.h doc/*: regenerated
Daniel
2005-01-25 23:45:06 +00:00
Daniel Veillard
1441251f85 a single lock version mostly avoid the cost penalty of the lock in case of
* dict.c parser.c include/libxml/dict.h: a single lock version
  mostly avoid the cost penalty of the lock in case of low
  parallelism, so applying that version instead.
Daniel
2005-01-21 23:53:26 +00:00
Daniel Veillard
1bb16a1888 patch from Gary Coady to fix a race in dict reference counting in
* dict.c: patch from Gary Coady to fix a race in dict reference
  counting in multithreaded apps.
Daniel
2005-01-21 16:55:41 +00:00
William M. Brack
ad0e67c57f fixed up some gcc warnings, no change to logic. New macro XML_CAST_FPTR to
* dict.c, xpath.c, include/libxml/hash.h: fixed up some gcc warnings,
  no change to logic.  New macro XML_CAST_FPTR to circumvent gcc
  warnings on function pointer <-> object pointer (a hack).
2004-12-01 14:35:10 +00:00
Daniel Veillard
6bb3e86d2c added xmlDictExists() to the dictionnary interface. applying
* dict.c include/libxml/dict.h: added xmlDictExists() to the
  dictionnary interface.
* xmlreader.c: applying xmlTextReaderHasAttributes fix for namespaces
  from Rob Richards
Daniel
2004-11-24 12:39:00 +00:00
William M. Brack
bf5cf2196c fixed bug introduced during OOM fixup causing problems with default
* SAX2.c: fixed bug introduced during OOM fixup causing problems
  with default namespace when a named prefix with the same href
  was present (reported on the mailing list by Karl Eichwalder.
* xmlstring.c: modified xmlCheckUTF8 with suggested code from
  Julius Mittenzwei.
* dict.c: added a typecast to try to avoid problem reported by
  Pascal Rodes.
2004-08-31 06:47:17 +00:00
Daniel Veillard
4773df2a58 added io1.c an example ox xmlIO usage and io1.res test result, fixed a
* doc/examples/*: added io1.c an example ox xmlIO usage and io1.res
  test result, fixed a awful lot of memory leaks showing up in
  testWriter.c, changed the examples and the Makefiles to test
  memory leaks.
* xmlwriter.c: fixed a memory leak
* Makefile.am: run the doc/examples regression tests as part of
  make tests
* xpath.c include/libxml/xpath.h: added xmlXPathCtxtCompile() to
  compile an XPath expression within a context, currently the goal
  is to be able to reuse the XSLT stylesheet dictionnary, but this
  opens the door to others possible optimizations.
* dict.c include/libxml/dict.h: added xmlDictCreateSub() which allows
  to build a new dictionnary based on another read-only dictionnary.
  This is needed for XSLT to keep the stylesheet dictionnary read-only
  while being able to reuse the strings for the transformation
  dictionnary.
* xinclude.c: fixed a dictionnar reference counting problem occuring
  when document parsing failed.
* testSAX.c: adding option --repeat for timing 100times the parsing
* doc/* : rebuilt all the docs
Daniel
2004-01-23 13:15:13 +00:00
Daniel Veillard
c82c57e69c some parser optimizations, xmllint --memory --timing --repeat --stream
* dict.c parser.c xmlstring.c: some parser optimizations,
  xmllint --memory --timing --repeat --stream ./db10000.xml
  went down from 16.5 secs to 15.5 secs.
Daniel
2004-01-12 16:24:34 +00:00
Daniel Veillard
e96a2a4bf0 adding repeated parsing and validating tests make the new DOM tree
* Makefile.am: adding repeated parsing and validating tests
* SAX2.c parser.c tree.c include/libxml/parser.h: make the new
  DOM tree building interfaces use the dictionary from the
  parsing context to build the element and attributes names
  as well as formatting spaces and short text nodes
* include/libxml/dict.h dict.c: added some reference counting
  for xmlDictPtr because they can be shared by documents and
  a parser context.
* xmlreader.c: a bit of cleanup, remove the specific tree freeing
  functions and use the standard ones now.
* xmllint.c: add --nodict
* python/libxml.c: fix a stupid bug so that ns() works on
  attribute nodes.
Daniel
2003-09-24 21:23:56 +00:00
Daniel Veillard
e72c508cd0 preparing a 2.6.0-beta2 release avoid a warning avoid duplicate code in
* configure.in: preparing a 2.6.0-beta2 release
* xmlIO.c: avoid a warning
* tree.c: avoid duplicate code in xmlReplaceNode as pointed out
  by Chris Ryland
* include/libxml/dict.h: add a QName access lookup to the
  dictionary.
* xmlreader.c include/libxml/xmlreader.h: adding const access
  based on the dictionary interface for string read from the
  reader, the node content access is still TODO, it's too different
Daniel
2003-09-19 12:44:05 +00:00
Daniel Veillard
c44cfdd7c1 the last patch broke unicity of returned strings, removed Daniel
* dict.c: the last patch broke unicity of returned strings, removed
Daniel
2003-09-18 10:12:02 +00:00
Daniel Veillard
536fad5aad valgrind found a newly introduced bug Daniel
* dict.c: valgrind found a newly introduced bug
Daniel
2003-09-18 10:05:56 +00:00
Daniel Veillard
ccc4d2b62e two small improvements Daniel
* dict.c xmlreader.c: two small improvements
Daniel
2003-09-17 21:27:31 +00:00
Daniel Veillard
81514ba478 do string allocations in large pools, allowing to find if a string pertain
* dict.c include/libxml/dict.h: do string allocations in large
  pools, allowing to find if a string pertain to a dict quickly
* xmllint.c: fix --stream --repeat --timing
* Makefile.am: the testThreads run output should be seen.
Daniel
2003-09-16 23:17:26 +00:00
Daniel Veillard
07cb8226c0 Time to commit 3 days of work rewriting the parser internal,
fixing bugs and migrating to SAX2 interface by default. There
is some work letf TODO, like namespace validation and attributes
normalization (this break C14N right now)
* Makefile.am: fixed the test rules
* include/libxml/SAX2.h include/libxml/parser.h
  include/libxml/parserInternals.h SAX2.c parser.c
  parserInternals.c: changing the parser, migrating to SAX2,
  adding new interface to switch back to SAX1 or initialize a
  SAX block for v1 or v2. Most of the namespace work is done
  below SAX, as well as attribute defaulting
* globals.c: changed initialization of the default SAX handlers
* hash.c tree.c include/libxml/hash.h: added QName specific handling
* xmlIO.c: small fix
* xmllint.c testSAX.c: provide a --sax1 switch to test the old
  version code path
* result/p3p result/p3p.sax result/noent/p3p test/p3p: the new code
  pointed out a typo in a very old test namespace
Daniel
2003-09-10 10:51:05 +00:00
Daniel Veillard
0fb1893539 allow to give -1 for undefined length in lookups first round of work on
* dict.c: allow to give -1 for undefined length in lookups
* include/libxml/parser.h parser.c parserInternals.c testSAX.c:
  first round of work on the new SAX2 interfaces, the API
  will change but commiting before changing for historical
  reference.
Daniel
2003-09-07 09:14:37 +00:00
Daniel Veillard
1af9a41f24 Adding new version of the SAX interface, it's not there yet, currently
* Makefile.am SAX2.c include/libxml/Makefile.am include/libxml/SAX2.h:
  Adding new version of the SAX interface, it's not there yet,
  currently just preparing the work
* globals.c parser.c SAX.c include/libxml/SAX.h
  include/libxml/globals.h include/libxml/parser.h: doing some
  refactoring of the SAXv1 interfaces, obsoleting a bunch of them
  while keeping functionalities, preparing SAX2 integration.
* dict.c: small cleanup.
Daniel
2003-08-20 22:54:39 +00:00
Daniel Veillard
6155d8aafa optimization when freeing hash tables. some tuning of buffer allocations
* dict.c hash.c: optimization when freeing hash tables.
* parser.c xmlIO.c include/libxml/tree.h: some tuning of buffer
  allocations
* parser.c parserInternals.c include/libxml/parser.h: keep a
  single allocated block for all the attributes callbacks,
  avoid useless malloc()/free()
* tree.c: do not realloc() when growing a buffer if the buffer
  ain't full, malloc/memcpy/free avoid copying memory.
Daniel
2003-08-19 15:01:28 +00:00
Daniel Veillard
2fdbd32d51 new dictionary module to keep a single instance of the names used by the
* dict.c include/libxml/dict.h Makefile.am include/libxml/Makefile.am:
  new dictionary module to keep a single instance of the names used
  by the parser
* DOCBparser.c HTMLparser.c parser.c parserInternals.c valid.c:
  switched all parsers to use the dictionary internally
* include/libxml/HTMLparser.h include/libxml/parser.h
  include/libxml/parserInternals.h include/libxml/valid.h:
  Some of the interfaces changed as a result to receive or return
  "const xmlChar *" instead of "xmlChar *", this is either
  insignificant from an user point of view or when the returning
  value changed, those function are really parser internal methods
  that no user code should really change
* doc/libxml2-api.xml doc/html/*: the API interface changed and
  the docs were regenerated
Daniel
2003-08-18 12:15:38 +00:00