From 9365ee1c464b1a4bda5325b9c5a16f9c09029d2a Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 3 Apr 2016 12:52:37 +0200 Subject: gnu: Add gnome-tweak-tool. * gnu/packages/patches/gnome-tweak-tool-search-paths.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/gnome.scm (gnome-tweak-tool): New variable. Signed-off-by: Leo Famulari --- .../patches/gnome-tweak-tool-search-paths.patch | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 gnu/packages/patches/gnome-tweak-tool-search-paths.patch (limited to 'gnu/packages/patches') diff --git a/gnu/packages/patches/gnome-tweak-tool-search-paths.patch b/gnu/packages/patches/gnome-tweak-tool-search-paths.patch new file mode 100644 index 0000000000..027c61b3af --- /dev/null +++ b/gnu/packages/patches/gnome-tweak-tool-search-paths.patch @@ -0,0 +1,52 @@ +Gnome-tweak-tool does not look at GSETTINGS_SCHEMA_PATH or XDG_DATA_DIRS, it +assumes that schemas are installed in one global directory +(GSETTINGS_SCHEMA_DIR/gsettingsschemadir). + +Guix/GuixSD uses a different directory for every gir package and has +packages pick-up files using XDG_DATA_DIRS. + +Upstream ticket: https://bugzilla.gnome.org/show_bug.cgi?id=764537 +janneke@gnu.org + +--- gnome-tweak-tool-3.18.1.orig/gtweak/gsettings.py 2015-04-08 15:21:32.000000000 +0200 ++++ gnome-tweak-tool-3.18.1/gtweak/gsettings.py 2016-04-03 11:26:38.658482704 +0200 +@@ -16,7 +16,8 @@ + # along with gnome-tweak-tool. If not, see . + + import logging +-import os.path ++import os ++import sys + import xml.dom.minidom + import gettext + +@@ -31,6 +32,13 @@ + class GSettingsMissingError(Exception): + pass + ++def file_from_path(path, file_name): ++ for dir in path: ++ f = os.path.join(dir, file_name) ++ if os.path.exists(f): ++ return f ++ return None ++ + class _GSettingsSchema: + def __init__(self, schema_name, schema_dir=None, schema_filename=None, **options): + if not schema_dir: +@@ -38,9 +46,14 @@ + if not schema_filename: + schema_filename = schema_name + ".gschema.xml" + ++ schema_prefix = os.path.join('glib-2.0', 'schemas') + schema_path = os.path.join(schema_dir, schema_filename) + if not os.path.exists(schema_path): +- logging.critical("Could not find schema %s" % schema_path) ++ schema_path = file_from_path(os.environ.get ('GSETTINGS_SCHEMA_PATH', '').split(os.path.pathsep), schema_filename) ++ if not (schema_path and os.path.exists(schema_path)): ++ schema_path = file_from_path(os.environ.get ('XDG_DATA_DIRS', '').split(os.path.pathsep), os.path.join(schema_prefix, schema_filename)) ++ if not (schema_path and os.path.exists(schema_path)): ++ logging.critical("Could not find schema %s" % schema_filename) + assert(False) + + self._schema_name = schema_name -- cgit v1.2.3 From 30897c60a4bb54936c228daf46e26377306da280 Mon Sep 17 00:00:00 2001 From: Efraim Flashner Date: Thu, 12 May 2016 21:38:56 +0300 Subject: gnu: mdadm: Update to 3.4. * gnu/packages/linux.scm (mdadm): Update to 3.4. [source]: Remove patch. * gnu/packages/patches/mdadm-gcc-4.9-fix.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Remove it. --- gnu/packages/patches/mdadm-gcc-4.9-fix.patch | 38 ---------------------------- 1 file changed, 38 deletions(-) delete mode 100644 gnu/packages/patches/mdadm-gcc-4.9-fix.patch (limited to 'gnu/packages/patches') diff --git a/gnu/packages/patches/mdadm-gcc-4.9-fix.patch b/gnu/packages/patches/mdadm-gcc-4.9-fix.patch deleted file mode 100644 index 222fd0ea32..0000000000 --- a/gnu/packages/patches/mdadm-gcc-4.9-fix.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 68641cdb646eaa15099c1d6cfff1eaa5dd2ac841 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen -Date: Tue, 24 Feb 2015 16:00:40 -0500 -Subject: [PATCH] write_super_imsm_spares(): C statements are terminated by ; - -Signed-off-by: Jes Sorensen -Signed-off-by: NeilBrown ---- - super-intel.c | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 819e0da..7f75b53 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -5115,13 +5115,13 @@ static int write_super_imsm_spares(struct intel_super *super, int doclose) - __u32 sum; - struct dl *d; - -- spare->mpb_size = __cpu_to_le32(sizeof(struct imsm_super)), -- spare->generation_num = __cpu_to_le32(1UL), -+ spare->mpb_size = __cpu_to_le32(sizeof(struct imsm_super)); -+ spare->generation_num = __cpu_to_le32(1UL); - spare->attributes = MPB_ATTRIB_CHECKSUM_VERIFY; -- spare->num_disks = 1, -- spare->num_raid_devs = 0, -- spare->cache_size = mpb->cache_size, -- spare->pwr_cycle_count = __cpu_to_le32(1), -+ spare->num_disks = 1; -+ spare->num_raid_devs = 0; -+ spare->cache_size = mpb->cache_size; -+ spare->pwr_cycle_count = __cpu_to_le32(1); - - snprintf((char *) spare->sig, MAX_SIGNATURE_LENGTH, - MPB_SIGNATURE MPB_VERSION_RAID0); --- -2.4.3 - -- cgit v1.2.3 From 7d0c3c8d018a4aff4ce42f863ce81242555ab119 Mon Sep 17 00:00:00 2001 From: Efraim Flashner Date: Mon, 16 May 2016 17:36:58 +0300 Subject: gnu: python-pandas: Update to 0.18.1. * gnu/packages/python.scm (python-pandas): Update to 0.18.1. [native-inputs]: Remove python-setuptools. [properties]: Define python2-pandas. (python2-pandas)[native-inputs]: Add python2-setuptools. * gnu/packages/patches/python-pandas-fix-tslib-test-failure.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Remove it. --- .../python-pandas-fix-tslib-test-failure.patch | 141 --------------------- 1 file changed, 141 deletions(-) delete mode 100644 gnu/packages/patches/python-pandas-fix-tslib-test-failure.patch (limited to 'gnu/packages/patches') diff --git a/gnu/packages/patches/python-pandas-fix-tslib-test-failure.patch b/gnu/packages/patches/python-pandas-fix-tslib-test-failure.patch deleted file mode 100644 index 62d6a38086..0000000000 --- a/gnu/packages/patches/python-pandas-fix-tslib-test-failure.patch +++ /dev/null @@ -1,141 +0,0 @@ -This patch is required to fix a test failure when python-dateutil version -2.5.2 or later is used. It is derived from the following commits: - -80ef4e06526b9b60cf24268454c9456585a790a3 -845ff974af6f7c3b3067cce8a7149b771c2be87 - -diff --git a/pandas/tseries/tests/test_tslib.py b/pandas/tseries/tests/test_tslib.py -index f0d5bf7..863bc6f 100644 ---- a/pandas/tseries/tests/test_tslib.py -+++ b/pandas/tseries/tests/test_tslib.py -@@ -474,6 +474,11 @@ def test_does_not_convert_mixed_integer(self): - good_date_string)) - - def test_parsers(self): -+ -+ # https://github.com/dateutil/dateutil/issues/217 -+ import dateutil -+ yearfirst = dateutil.__version__ >= LooseVersion('2.5.0') -+ - cases = {'2011-01-01': datetime.datetime(2011, 1, 1), - '2Q2005': datetime.datetime(2005, 4, 1), - '2Q05': datetime.datetime(2005, 4, 1), -@@ -527,20 +532,26 @@ def test_parsers(self): - } - - for date_str, expected in compat.iteritems(cases): -- result1, _, _ = tools.parse_time_string(date_str) -- result2 = to_datetime(date_str) -- result3 = to_datetime([date_str]) -- result4 = to_datetime(np.array([date_str], dtype=object)) -- result5 = Timestamp(date_str) -- result6 = DatetimeIndex([date_str])[0] -- result7 = date_range(date_str, freq='S', periods=1) -+ result1, _, _ = tools.parse_time_string(date_str, -+ yearfirst=yearfirst) -+ result2 = to_datetime(date_str, yearfirst=yearfirst) -+ result3 = to_datetime([date_str], yearfirst=yearfirst) -+ result4 = to_datetime(np.array([date_str], dtype=object), -+ yearfirst=yearfirst) -+ result6 = DatetimeIndex([date_str], yearfirst=yearfirst)[0] - self.assertEqual(result1, expected) - self.assertEqual(result2, expected) - self.assertEqual(result3, expected) - self.assertEqual(result4, expected) -- self.assertEqual(result5, expected) - self.assertEqual(result6, expected) -- self.assertEqual(result7, expected) -+ -+ # these really need to have yearfist, but we don't support -+ if not yearfirst: -+ result5 = Timestamp(date_str) -+ self.assertEqual(result5, expected) -+ result7 = date_range(date_str, freq='S', periods=1, -+ yearfirst=yearfirst) -+ self.assertEqual(result7, expected) - - # NaT - result1, _, _ = tools.parse_time_string('NaT') -@@ -589,23 +589,62 @@ def test_parsers_quarter_invalid(self): - self.assertRaises(ValueError, tools.parse_time_string, case) - - def test_parsers_dayfirst_yearfirst(self): -+ -+ # https://github.com/dateutil/dateutil/issues/217 -+ # this issue was closed -+ import dateutil -+ is_compat_version = dateutil.__version__ >= LooseVersion('2.5.2') -+ if is_compat_version: -+ dayfirst_yearfirst1 = datetime.datetime(2010, 12, 11) -+ dayfirst_yearfirst2 = datetime.datetime(2020, 12, 21) -+ else: -+ dayfirst_yearfirst1 = datetime.datetime(2010, 11, 12) -+ dayfirst_yearfirst2 = datetime.datetime(2020, 12, 21) -+ - # str : dayfirst, yearfirst, expected -- cases = {'10-11-12': [(False, False, datetime.datetime(2012, 10, 11)), -- (True, False, datetime.datetime(2012, 11, 10)), -- (False, True, datetime.datetime(2010, 11, 12)), -- (True, True, datetime.datetime(2010, 11, 12))], -- '20/12/21': [(False, False, datetime.datetime(2021, 12, 20)), -- (True, False, datetime.datetime(2021, 12, 20)), -- (False, True, datetime.datetime(2020, 12, 21)), -- (True, True, datetime.datetime(2020, 12, 21))]} -+ cases = {'10-11-12': [(False, False, False, -+ datetime.datetime(2012, 10, 11)), -+ (True, False, False, -+ datetime.datetime(2012, 11, 10)), -+ (False, True, False, -+ datetime.datetime(2010, 11, 12)), -+ (True, True, False, dayfirst_yearfirst1)], -+ '20/12/21': [(False, False, False, -+ datetime.datetime(2021, 12, 20)), -+ (True, False, False, -+ datetime.datetime(2021, 12, 20)), -+ (False, True, False, -+ datetime.datetime(2020, 12, 21)), -+ (True, True, True, dayfirst_yearfirst2)]} - - tm._skip_if_no_dateutil() - from dateutil.parser import parse - for date_str, values in compat.iteritems(cases): -- for dayfirst, yearfirst, expected in values: -- result1, _, _ = tools.parse_time_string(date_str, -- dayfirst=dayfirst, -- yearfirst=yearfirst) -+ for dayfirst, yearfirst, is_compat, expected in values: -+ -+ f = lambda x: tools.parse_time_string(x, -+ dayfirst=dayfirst, -+ yearfirst=yearfirst) -+ -+ # we now have an invalid parse -+ if is_compat and is_compat_version: -+ self.assertRaises(tslib.DateParseError, f, date_str) -+ -+ def f(date_str): -+ return to_datetime(date_str, dayfirst=dayfirst, -+ yearfirst=yearfirst) -+ -+ self.assertRaises(ValueError, f, date_str) -+ -+ def f(date_str): -+ return DatetimeIndex([date_str], dayfirst=dayfirst, -+ yearfirst=yearfirst)[0] -+ -+ self.assertRaises(ValueError, f, date_str) -+ -+ continue -+ -+ result1, _, _ = f(date_str) - - result2 = to_datetime(date_str, dayfirst=dayfirst, - yearfirst=yearfirst) -@@ -614,7 +653,6 @@ def test_parsers_dayfirst_yearfirst(self): - yearfirst=yearfirst)[0] - - # Timestamp doesn't support dayfirst and yearfirst -- - self.assertEqual(result1, expected) - self.assertEqual(result2, expected) - self.assertEqual(result3, expected) -- cgit v1.2.3 From 1c29f3ef8452860c4301d7ae57c89ac5956d1663 Mon Sep 17 00:00:00 2001 From: Federico Beffa Date: Tue, 17 May 2016 14:13:56 +0200 Subject: gnu: emacs-constants: Remove old patch. * gnu/packages/patches/emacs-constants-lisp-like.patch: Remove it. * gnu/local.mk (dist_patch_DATA): Remove entry for above patch. --- .../patches/emacs-constants-lisp-like.patch | 81 ---------------------- 1 file changed, 81 deletions(-) delete mode 100644 gnu/packages/patches/emacs-constants-lisp-like.patch (limited to 'gnu/packages/patches') diff --git a/gnu/packages/patches/emacs-constants-lisp-like.patch b/gnu/packages/patches/emacs-constants-lisp-like.patch deleted file mode 100644 index 5ec37f3adf..0000000000 --- a/gnu/packages/patches/emacs-constants-lisp-like.patch +++ /dev/null @@ -1,81 +0,0 @@ -Add Scheme support - ---- constants/constants.el.orig 2015-12-26 17:44:31.734520833 +0100 -+++ constants/constants.el 2015-12-30 17:41:28.402871263 +0100 -@@ -684,6 +684,33 @@ - - (eval-when-compile (defvar ctable)) - -+(defun constants-is-lisp-like (mode) -+ (save-match-data -+ (string-match "\\(lisp\\|scheme\\)" (symbol-name mode)))) -+ -+(defun constants-is-set-like () -+ (save-excursion -+ (condition-case nil -+ (save-match-data -+ (progn (up-list -1) -+ (or (looking-at "(set[qf!]?\\>") (looking-at "(define\\>")))) -+ (error nil)))) ; return value nil means use default -+ -+;;;###autoload -+(defun constants-lisp-like-function () -+ "Check context for constants insertion." -+ (if (constants-is-set-like) -+ '(emacs-lisp-mode "%n %v%t; %d %u" "e" "(* %p %v)") -+ '(emacs-lisp-mode "(%n %v)%t; %d %u" "e" "(* %p %v)"))) -+ -+;;;###autoload -+(mapc (lambda (mode-hook) -+ (add-hook mode-hook -+ (lambda () -+ (setq constants-language-function -+ 'constants-lisp-like-function)))) -+ '(scheme-mode-hook emacs-lisp-mode-hook lisp-mode-hook)) -+ - ;;;###autoload - (defun constants-insert (&optional unit-system names) - "Insert one or more natural constant definitions in source code. -@@ -826,8 +853,9 @@ - (funcall process-func ins)) - ;; Here comes the insertion stuff for source code editing modes. - ;; First make sure we start a new line -- (if (string-match -- "\\S-" (buffer-substring (point-at-bol) (point-at-eol))) -+ (if (and (string-match -+ "\\S-" (buffer-substring (point-at-bol) (point-at-eol))) -+ (not (constants-is-lisp-like mode))) - ;; non-empty line, insert after this line - (progn - (end-of-line 1) -@@ -841,13 +869,24 @@ - (if (string-match "\\(.*\\)%t\\(.*\\)" line) - (let ((comment-column 42)) - (insert (match-string 1 line)) -- (indent-to comment-column) -- (insert (match-string 2 line))) -+ (if (and (constants-is-lisp-like mode) -+ (or (constants-is-set-like) -+ (null clist))) -+ (save-excursion -+ (progn -+ (move-to-column comment-column t) -+ (insert (match-string 2 line)) -+ ;; insert a newline such that paredit's M-) can mode -+ ;; the closing parentheses to the next line. -+ (newline-and-indent))) -+ (progn -+ (indent-to comment-column) -+ (insert (match-string 2 line))))) - (insert line))) -- (if constants-indent-code -- (newline-and-indent) -- (newline)))))) -- -+ (unless (and (constants-is-lisp-like mode) (null clist)) -+ (if constants-indent-code -+ (newline-and-indent) -+ (newline))))))) - ;;;###autoload - (defun constants-get (&optional const message) - "Return the value of CONST as defined in the constants package. -- cgit v1.2.3 From fb2b0f5c87321f5aab0dc13130ef92a76040fbe3 Mon Sep 17 00:00:00 2001 From: Leo Famulari Date: Tue, 17 May 2016 00:20:17 -0400 Subject: gnu: gd: Fix-CVE-2016-3074. * gnu/packages/patches/gd-CVE-2016-3074.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/gd.scm (gd)[source]: Use it. --- gnu/packages/patches/gd-CVE-2016-3074.patch | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 gnu/packages/patches/gd-CVE-2016-3074.patch (limited to 'gnu/packages/patches') diff --git a/gnu/packages/patches/gd-CVE-2016-3074.patch b/gnu/packages/patches/gd-CVE-2016-3074.patch new file mode 100644 index 0000000000..a90c51d77b --- /dev/null +++ b/gnu/packages/patches/gd-CVE-2016-3074.patch @@ -0,0 +1,36 @@ +Adapted from upstream commit 2bb97f407c1145c850416a3bfbcc8cf124e68a19 +(gd2: handle corrupt images better (CVE-2016-3074)). + +This patch omits the upstream changes to '.gitignore', and the test +added in files 'tests/Makefile.am', 'tests/gd2/gd2_read_corrupt.c', and +'tests/gd2/invalid_neg_size.gd2'. + +We omit the test because its input data, +'tests/gd2/invalid_neg_size.gd2', is provided as a binary Git diff, +which is not supported by `patch`. + +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-3074 +https://github.com/libgd/libgd/commit/2bb97f407c1145c850416a3bfbcc8cf124e68a19 +--- + .gitignore | 1 + + src/gd_gd2.c | 2 ++ + tests/Makefile.am | 3 ++- + tests/gd2/gd2_read_corrupt.c | 25 +++++++++++++++++++++++++ + tests/gd2/invalid_neg_size.gd2 | Bin 0 -> 1676 bytes + 5 files changed, 30 insertions(+), 1 deletion(-) + create mode 100644 tests/gd2/gd2_read_corrupt.c + create mode 100644 tests/gd2/invalid_neg_size.gd2 + +diff --git a/src/gd_gd2.c b/src/gd_gd2.c +index 6f28461..a50b33d 100644 +--- a/src/gd_gd2.c ++++ b/src/gd_gd2.c +@@ -165,6 +165,8 @@ _gd2GetHeader (gdIOCtxPtr in, int *sx, int *sy, + if (gdGetInt (&cidx[i].size, in) != 1) { + goto fail2; + }; ++ if (cidx[i].offset < 0 || cidx[i].size < 0) ++ goto fail2; + }; + *chunkIdx = cidx; + }; -- cgit v1.2.3 From 119b83989dd9edd1e8ba6cd379d159d024cbc61d Mon Sep 17 00:00:00 2001 From: Leo Famulari Date: Wed, 18 May 2016 13:26:17 -0400 Subject: gnu: expat: Fix CVE-2016-0718. Improve fix for CVE-2015-1283. * gnu/packages/patches/expat-CVE-2015-1283-refix.patch, gnu/packages/patches/expat-CVE-2016-0718.patch: New files. * gnu/local.mk (dist_patch_DATA): Add them. * gnu/packages/xml.scm (expat)[replacement]: New field. (expat/fixed): New variable. [source]: Use new patches. --- .../patches/expat-CVE-2015-1283-refix.patch | 42 ++ gnu/packages/patches/expat-CVE-2016-0718.patch | 761 +++++++++++++++++++++ 2 files changed, 803 insertions(+) create mode 100644 gnu/packages/patches/expat-CVE-2015-1283-refix.patch create mode 100644 gnu/packages/patches/expat-CVE-2016-0718.patch (limited to 'gnu/packages/patches') diff --git a/gnu/packages/patches/expat-CVE-2015-1283-refix.patch b/gnu/packages/patches/expat-CVE-2015-1283-refix.patch new file mode 100644 index 0000000000..af5e3bcc3e --- /dev/null +++ b/gnu/packages/patches/expat-CVE-2015-1283-refix.patch @@ -0,0 +1,42 @@ +Update previous fix for CVE-2015-1283 to not rely on undefined behavior. + +Copied from Debian, as found in Debian package version 2.1.0-6+deb8u2. + +https://sources.debian.net/src/expat/2.1.0-6%2Bdeb8u2/debian/patches/CVE-2015-1283-refix.patch/ + +From 29a11774d8ebbafe8418b4a5ffb4cc1160b194a1 Mon Sep 17 00:00:00 2001 +From: Pascal Cuoq +Date: Sun, 15 May 2016 09:05:46 +0200 +Subject: [PATCH] Avoid relying on undefined behavior in CVE-2015-1283 fix. + +--- + expat/lib/xmlparse.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/lib/xmlparse.c b/lib/xmlparse.c +index 13e080d..cdb12ef 100644 +--- a/lib/xmlparse.c ++++ b/lib/xmlparse.c +@@ -1695,7 +1695,8 @@ XML_GetBuffer(XML_Parser parser, int len + } + + if (len > bufferLim - bufferEnd) { +- int neededSize = len + (int)(bufferEnd - bufferPtr); ++ /* Do not invoke signed arithmetic overflow: */ ++ int neededSize = (int) ((unsigned)len + (unsigned)(bufferEnd - bufferPtr)); + /* BEGIN MOZILLA CHANGE (sanity check neededSize) */ + if (neededSize < 0) { + errorCode = XML_ERROR_NO_MEMORY; +@@ -1729,7 +1730,8 @@ XML_GetBuffer(XML_Parser parser, int len + if (bufferSize == 0) + bufferSize = INIT_BUFFER_SIZE; + do { +- bufferSize *= 2; ++ /* Do not invoke signed arithmetic overflow: */ ++ bufferSize = (int) (2U * (unsigned) bufferSize); + /* BEGIN MOZILLA CHANGE (prevent infinite loop on overflow) */ + } while (bufferSize < neededSize && bufferSize > 0); + /* END MOZILLA CHANGE */ +-- +2.8.2 + diff --git a/gnu/packages/patches/expat-CVE-2016-0718.patch b/gnu/packages/patches/expat-CVE-2016-0718.patch new file mode 100644 index 0000000000..22436c20cc --- /dev/null +++ b/gnu/packages/patches/expat-CVE-2016-0718.patch @@ -0,0 +1,761 @@ +Fix CVE-2016-0718. + +Copied from Debian, as found in Debian package version 2.1.0-6+deb8u2. + +https://sources.debian.net/src/expat/2.1.0-6%2Bdeb8u2/debian/patches/CVE-2016-0718-v2-2-1.patch/ + +From cdfcb1b5c95e93b00ae9e9d25708b4a3bee72c15 Mon Sep 17 00:00:00 2001 +From: Sebastian Pipping +Date: Mon, 2 May 2016 00:02:44 +0200 +Subject: [PATCH] Address CVE-2016-0718 (/patch/ version 2.2.1) + +* Out of bounds memory access when doing text conversion on malformed input +* Integer overflow related to memory allocation + +Reported by Gustavo Grieco + +Patch credits go to +* Christian Heimes +* Karl Waclawek +* Gustavo Grieco +* Sebastian Pipping +* Pascal Cuoq +--- + expat/lib/xmlparse.c | 34 +++++++++----- + expat/lib/xmltok.c | 115 +++++++++++++++++++++++++++++++++++------------- + expat/lib/xmltok.h | 10 ++++- + expat/lib/xmltok_impl.c | 62 +++++++++++++------------- + 4 files changed, 146 insertions(+), 75 deletions(-) + +diff --git a/lib/xmlparse.c b/lib/xmlparse.c +index e308c79..13e080d 100644 +--- a/lib/xmlparse.c ++++ b/lib/xmlparse.c +@@ -2436,11 +2436,11 @@ doContent(XML_Parser parser, + for (;;) { + int bufSize; + int convLen; +- XmlConvert(enc, ++ const enum XML_Convert_Result convert_res = XmlConvert(enc, + &fromPtr, rawNameEnd, + (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); + convLen = (int)(toPtr - (XML_Char *)tag->buf); +- if (fromPtr == rawNameEnd) { ++ if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) { + tag->name.strLen = convLen; + break; + } +@@ -2661,11 +2661,11 @@ doContent(XML_Parser parser, + if (MUST_CONVERT(enc, s)) { + for (;;) { + ICHAR *dataPtr = (ICHAR *)dataBuf; +- XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); ++ const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); + *eventEndPP = s; + charDataHandler(handlerArg, dataBuf, + (int)(dataPtr - (ICHAR *)dataBuf)); +- if (s == next) ++ if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) + break; + *eventPP = s; + } +@@ -3269,11 +3269,11 @@ doCdataSection(XML_Parser parser, + if (MUST_CONVERT(enc, s)) { + for (;;) { + ICHAR *dataPtr = (ICHAR *)dataBuf; +- XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); ++ const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); + *eventEndPP = next; + charDataHandler(handlerArg, dataBuf, + (int)(dataPtr - (ICHAR *)dataBuf)); +- if (s == next) ++ if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) + break; + *eventPP = s; + } +@@ -5350,6 +5350,7 @@ reportDefault(XML_Parser parser, const ENCODING *enc, + const char *s, const char *end) + { + if (MUST_CONVERT(enc, s)) { ++ enum XML_Convert_Result convert_res; + const char **eventPP; + const char **eventEndPP; + if (enc == encoding) { +@@ -5362,11 +5363,11 @@ reportDefault(XML_Parser parser, const ENCODING *enc, + } + do { + ICHAR *dataPtr = (ICHAR *)dataBuf; +- XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); ++ convert_res = XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); + *eventEndPP = s; + defaultHandler(handlerArg, dataBuf, (int)(dataPtr - (ICHAR *)dataBuf)); + *eventPP = s; +- } while (s != end); ++ } while ((convert_res != XML_CONVERT_COMPLETED) && (convert_res != XML_CONVERT_INPUT_INCOMPLETE)); + } + else + defaultHandler(handlerArg, (XML_Char *)s, (int)((XML_Char *)end - (XML_Char *)s)); +@@ -6169,8 +6170,8 @@ poolAppend(STRING_POOL *pool, const ENCODING *enc, + if (!pool->ptr && !poolGrow(pool)) + return NULL; + for (;;) { +- XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); +- if (ptr == end) ++ const enum XML_Convert_Result convert_res = XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); ++ if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) + break; + if (!poolGrow(pool)) + return NULL; +@@ -6254,8 +6255,13 @@ poolGrow(STRING_POOL *pool) + } + } + if (pool->blocks && pool->start == pool->blocks->s) { +- int blockSize = (int)(pool->end - pool->start)*2; +- BLOCK *temp = (BLOCK *) ++ BLOCK *temp; ++ int blockSize = (int)((unsigned)(pool->end - pool->start)*2U); ++ ++ if (blockSize < 0) ++ return XML_FALSE; ++ ++ temp = (BLOCK *) + pool->mem->realloc_fcn(pool->blocks, + (offsetof(BLOCK, s) + + blockSize * sizeof(XML_Char))); +@@ -6270,6 +6276,10 @@ poolGrow(STRING_POOL *pool) + else { + BLOCK *tem; + int blockSize = (int)(pool->end - pool->start); ++ ++ if (blockSize < 0) ++ return XML_FALSE; ++ + if (blockSize < INIT_BLOCK_SIZE) + blockSize = INIT_BLOCK_SIZE; + else +diff --git a/lib/xmltok.c b/lib/xmltok.c +index bf09dfc..cb98ce1 100644 +--- a/lib/xmltok.c ++++ b/lib/xmltok.c +@@ -318,39 +318,55 @@ enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */ + UTF8_cval4 = 0xf0 + }; + +-static void PTRCALL ++static enum XML_Convert_Result PTRCALL + utf8_toUtf8(const ENCODING *enc, + const char **fromP, const char *fromLim, + char **toP, const char *toLim) + { ++ enum XML_Convert_Result res = XML_CONVERT_COMPLETED; + char *to; + const char *from; + if (fromLim - *fromP > toLim - *toP) { + /* Avoid copying partial characters. */ ++ res = XML_CONVERT_OUTPUT_EXHAUSTED; + for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--) + if (((unsigned char)fromLim[-1] & 0xc0) != 0x80) + break; + } +- for (to = *toP, from = *fromP; from != fromLim; from++, to++) ++ for (to = *toP, from = *fromP; (from < fromLim) && (to < toLim); from++, to++) + *to = *from; + *fromP = from; + *toP = to; ++ ++ if ((to == toLim) && (from < fromLim)) ++ return XML_CONVERT_OUTPUT_EXHAUSTED; ++ else ++ return res; + } + +-static void PTRCALL ++static enum XML_Convert_Result PTRCALL + utf8_toUtf16(const ENCODING *enc, + const char **fromP, const char *fromLim, + unsigned short **toP, const unsigned short *toLim) + { ++ enum XML_Convert_Result res = XML_CONVERT_COMPLETED; + unsigned short *to = *toP; + const char *from = *fromP; +- while (from != fromLim && to != toLim) { ++ while (from < fromLim && to < toLim) { + switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) { + case BT_LEAD2: ++ if (fromLim - from < 2) { ++ res = XML_CONVERT_INPUT_INCOMPLETE; ++ break; ++ } + *to++ = (unsigned short)(((from[0] & 0x1f) << 6) | (from[1] & 0x3f)); + from += 2; + break; + case BT_LEAD3: ++ if (fromLim - from < 3) { ++ res = XML_CONVERT_INPUT_INCOMPLETE; ++ break; ++ } + *to++ = (unsigned short)(((from[0] & 0xf) << 12) + | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f)); + from += 3; +@@ -358,8 +374,14 @@ utf8_toUtf16(const ENCODING *enc, + case BT_LEAD4: + { + unsigned long n; +- if (to + 1 == toLim) ++ if (toLim - to < 2) { ++ res = XML_CONVERT_OUTPUT_EXHAUSTED; + goto after; ++ } ++ if (fromLim - from < 4) { ++ res = XML_CONVERT_INPUT_INCOMPLETE; ++ goto after; ++ } + n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12) + | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f); + n -= 0x10000; +@@ -377,6 +399,7 @@ utf8_toUtf16(const ENCODING *enc, + after: + *fromP = from; + *toP = to; ++ return res; + } + + #ifdef XML_NS +@@ -425,7 +448,7 @@ static const struct normal_encoding internal_utf8_encoding = { + STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) + }; + +-static void PTRCALL ++static enum XML_Convert_Result PTRCALL + latin1_toUtf8(const ENCODING *enc, + const char **fromP, const char *fromLim, + char **toP, const char *toLim) +@@ -433,30 +456,35 @@ latin1_toUtf8(const ENCODING *enc, + for (;;) { + unsigned char c; + if (*fromP == fromLim) +- break; ++ return XML_CONVERT_COMPLETED; + c = (unsigned char)**fromP; + if (c & 0x80) { + if (toLim - *toP < 2) +- break; ++ return XML_CONVERT_OUTPUT_EXHAUSTED; + *(*toP)++ = (char)((c >> 6) | UTF8_cval2); + *(*toP)++ = (char)((c & 0x3f) | 0x80); + (*fromP)++; + } + else { + if (*toP == toLim) +- break; ++ return XML_CONVERT_OUTPUT_EXHAUSTED; + *(*toP)++ = *(*fromP)++; + } + } + } + +-static void PTRCALL ++static enum XML_Convert_Result PTRCALL + latin1_toUtf16(const ENCODING *enc, + const char **fromP, const char *fromLim, + unsigned short **toP, const unsigned short *toLim) + { +- while (*fromP != fromLim && *toP != toLim) ++ while (*fromP < fromLim && *toP < toLim) + *(*toP)++ = (unsigned char)*(*fromP)++; ++ ++ if ((*toP == toLim) && (*fromP < fromLim)) ++ return XML_CONVERT_OUTPUT_EXHAUSTED; ++ else ++ return XML_CONVERT_COMPLETED; + } + + #ifdef XML_NS +@@ -483,13 +511,18 @@ static const struct normal_encoding latin1_encoding = { + STANDARD_VTABLE(sb_) + }; + +-static void PTRCALL ++static enum XML_Convert_Result PTRCALL + ascii_toUtf8(const ENCODING *enc, + const char **fromP, const char *fromLim, + char **toP, const char *toLim) + { +- while (*fromP != fromLim && *toP != toLim) ++ while (*fromP < fromLim && *toP < toLim) + *(*toP)++ = *(*fromP)++; ++ ++ if ((*toP == toLim) && (*fromP < fromLim)) ++ return XML_CONVERT_OUTPUT_EXHAUSTED; ++ else ++ return XML_CONVERT_COMPLETED; + } + + #ifdef XML_NS +@@ -536,13 +569,14 @@ unicode_byte_type(char hi, char lo) + } + + #define DEFINE_UTF16_TO_UTF8(E) \ +-static void PTRCALL \ ++static enum XML_Convert_Result PTRCALL \ + E ## toUtf8(const ENCODING *enc, \ + const char **fromP, const char *fromLim, \ + char **toP, const char *toLim) \ + { \ +- const char *from; \ +- for (from = *fromP; from != fromLim; from += 2) { \ ++ const char *from = *fromP; \ ++ fromLim = from + (((fromLim - from) >> 1) << 1); /* shrink to even */ \ ++ for (; from < fromLim; from += 2) { \ + int plane; \ + unsigned char lo2; \ + unsigned char lo = GET_LO(from); \ +@@ -552,7 +586,7 @@ E ## toUtf8(const ENCODING *enc, \ + if (lo < 0x80) { \ + if (*toP == toLim) { \ + *fromP = from; \ +- return; \ ++ return XML_CONVERT_OUTPUT_EXHAUSTED; \ + } \ + *(*toP)++ = lo; \ + break; \ +@@ -562,7 +596,7 @@ E ## toUtf8(const ENCODING *enc, \ + case 0x4: case 0x5: case 0x6: case 0x7: \ + if (toLim - *toP < 2) { \ + *fromP = from; \ +- return; \ ++ return XML_CONVERT_OUTPUT_EXHAUSTED; \ + } \ + *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \ + *(*toP)++ = ((lo & 0x3f) | 0x80); \ +@@ -570,7 +604,7 @@ E ## toUtf8(const ENCODING *enc, \ + default: \ + if (toLim - *toP < 3) { \ + *fromP = from; \ +- return; \ ++ return XML_CONVERT_OUTPUT_EXHAUSTED; \ + } \ + /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \ + *(*toP)++ = ((hi >> 4) | UTF8_cval3); \ +@@ -580,7 +614,11 @@ E ## toUtf8(const ENCODING *enc, \ + case 0xD8: case 0xD9: case 0xDA: case 0xDB: \ + if (toLim - *toP < 4) { \ + *fromP = from; \ +- return; \ ++ return XML_CONVERT_OUTPUT_EXHAUSTED; \ ++ } \ ++ if (fromLim - from < 4) { \ ++ *fromP = from; \ ++ return XML_CONVERT_INPUT_INCOMPLETE; \ + } \ + plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \ + *(*toP)++ = ((plane >> 2) | UTF8_cval4); \ +@@ -596,20 +634,32 @@ E ## toUtf8(const ENCODING *enc, \ + } \ + } \ + *fromP = from; \ ++ if (from < fromLim) \ ++ return XML_CONVERT_INPUT_INCOMPLETE; \ ++ else \ ++ return XML_CONVERT_COMPLETED; \ + } + + #define DEFINE_UTF16_TO_UTF16(E) \ +-static void PTRCALL \ ++static enum XML_Convert_Result PTRCALL \ + E ## toUtf16(const ENCODING *enc, \ + const char **fromP, const char *fromLim, \ + unsigned short **toP, const unsigned short *toLim) \ + { \ ++ enum XML_Convert_Result res = XML_CONVERT_COMPLETED; \ ++ fromLim = *fromP + (((fromLim - *fromP) >> 1) << 1); /* shrink to even */ \ + /* Avoid copying first half only of surrogate */ \ + if (fromLim - *fromP > ((toLim - *toP) << 1) \ +- && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) \ ++ && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) { \ + fromLim -= 2; \ +- for (; *fromP != fromLim && *toP != toLim; *fromP += 2) \ ++ res = XML_CONVERT_INPUT_INCOMPLETE; \ ++ } \ ++ for (; *fromP < fromLim && *toP < toLim; *fromP += 2) \ + *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \ ++ if ((*toP == toLim) && (*fromP < fromLim)) \ ++ return XML_CONVERT_OUTPUT_EXHAUSTED; \ ++ else \ ++ return res; \ + } + + #define SET2(ptr, ch) \ +@@ -1288,7 +1338,7 @@ unknown_isInvalid(const ENCODING *enc, const char *p) + return (c & ~0xFFFF) || checkCharRefNumber(c) < 0; + } + +-static void PTRCALL ++static enum XML_Convert_Result PTRCALL + unknown_toUtf8(const ENCODING *enc, + const char **fromP, const char *fromLim, + char **toP, const char *toLim) +@@ -1299,21 +1349,21 @@ unknown_toUtf8(const ENCODING *enc, + const char *utf8; + int n; + if (*fromP == fromLim) +- break; ++ return XML_CONVERT_COMPLETED; + utf8 = uenc->utf8[(unsigned char)**fromP]; + n = *utf8++; + if (n == 0) { + int c = uenc->convert(uenc->userData, *fromP); + n = XmlUtf8Encode(c, buf); + if (n > toLim - *toP) +- break; ++ return XML_CONVERT_OUTPUT_EXHAUSTED; + utf8 = buf; + *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] + - (BT_LEAD2 - 2)); + } + else { + if (n > toLim - *toP) +- break; ++ return XML_CONVERT_OUTPUT_EXHAUSTED; + (*fromP)++; + } + do { +@@ -1322,13 +1372,13 @@ unknown_toUtf8(const ENCODING *enc, + } + } + +-static void PTRCALL ++static enum XML_Convert_Result PTRCALL + unknown_toUtf16(const ENCODING *enc, + const char **fromP, const char *fromLim, + unsigned short **toP, const unsigned short *toLim) + { + const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); +- while (*fromP != fromLim && *toP != toLim) { ++ while (*fromP < fromLim && *toP < toLim) { + unsigned short c = uenc->utf16[(unsigned char)**fromP]; + if (c == 0) { + c = (unsigned short) +@@ -1340,6 +1390,11 @@ unknown_toUtf16(const ENCODING *enc, + (*fromP)++; + *(*toP)++ = c; + } ++ ++ if ((*toP == toLim) && (*fromP < fromLim)) ++ return XML_CONVERT_OUTPUT_EXHAUSTED; ++ else ++ return XML_CONVERT_COMPLETED; + } + + ENCODING * +@@ -1503,7 +1558,7 @@ initScan(const ENCODING * const *encodingTable, + { + const ENCODING **encPtr; + +- if (ptr == end) ++ if (ptr >= end) + return XML_TOK_NONE; + encPtr = enc->encPtr; + if (ptr + 1 == end) { +diff --git a/lib/xmltok.h b/lib/xmltok.h +index ca867aa..752007e 100644 +--- a/lib/xmltok.h ++++ b/lib/xmltok.h +@@ -130,6 +130,12 @@ typedef int (PTRCALL *SCANNER)(const ENCODING *, + const char *, + const char **); + ++enum XML_Convert_Result { ++ XML_CONVERT_COMPLETED = 0, ++ XML_CONVERT_INPUT_INCOMPLETE = 1, ++ XML_CONVERT_OUTPUT_EXHAUSTED = 2 /* and therefore potentially input remaining as well */ ++}; ++ + struct encoding { + SCANNER scanners[XML_N_STATES]; + SCANNER literalScanners[XML_N_LITERAL_TYPES]; +@@ -158,12 +164,12 @@ struct encoding { + const char *ptr, + const char *end, + const char **badPtr); +- void (PTRCALL *utf8Convert)(const ENCODING *enc, ++ enum XML_Convert_Result (PTRCALL *utf8Convert)(const ENCODING *enc, + const char **fromP, + const char *fromLim, + char **toP, + const char *toLim); +- void (PTRCALL *utf16Convert)(const ENCODING *enc, ++ enum XML_Convert_Result (PTRCALL *utf16Convert)(const ENCODING *enc, + const char **fromP, + const char *fromLim, + unsigned short **toP, +diff --git a/lib/xmltok_impl.c b/lib/xmltok_impl.c +index 9c2895b..6c5a3ba 100644 +--- a/lib/xmltok_impl.c ++++ b/lib/xmltok_impl.c +@@ -93,13 +93,13 @@ static int PTRCALL + PREFIX(scanComment)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) + { +- if (ptr != end) { ++ if (ptr < end) { + if (!CHAR_MATCHES(enc, ptr, ASCII_MINUS)) { + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } + ptr += MINBPC(enc); +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + INVALID_CASES(ptr, nextTokPtr) + case BT_MINUS: +@@ -147,7 +147,7 @@ PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + case BT_PERCNT: + if (ptr + MINBPC(enc) == end) +@@ -233,7 +233,7 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr, + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) + case BT_S: case BT_CR: case BT_LF: +@@ -242,7 +242,7 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr, + return XML_TOK_INVALID; + } + ptr += MINBPC(enc); +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + INVALID_CASES(ptr, nextTokPtr) + case BT_QUEST: +@@ -305,7 +305,7 @@ static int PTRCALL + PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) + { +- if (ptr == end) ++ if (ptr >= end) + return XML_TOK_NONE; + if (MINBPC(enc) > 1) { + size_t n = end - ptr; +@@ -348,7 +348,7 @@ PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, + ptr += MINBPC(enc); + break; + } +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + #define LEAD_CASE(n) \ + case BT_LEAD ## n: \ +@@ -391,11 +391,11 @@ PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) + case BT_S: case BT_CR: case BT_LF: +- for (ptr += MINBPC(enc); ptr != end; ptr += MINBPC(enc)) { ++ for (ptr += MINBPC(enc); ptr < end; ptr += MINBPC(enc)) { + switch (BYTE_TYPE(enc, ptr)) { + case BT_S: case BT_CR: case BT_LF: + break; +@@ -432,7 +432,7 @@ static int PTRCALL + PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) + { +- if (ptr != end) { ++ if (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + case BT_DIGIT: + case BT_HEX: +@@ -441,7 +441,7 @@ PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } +- for (ptr += MINBPC(enc); ptr != end; ptr += MINBPC(enc)) { ++ for (ptr += MINBPC(enc); ptr < end; ptr += MINBPC(enc)) { + switch (BYTE_TYPE(enc, ptr)) { + case BT_DIGIT: + case BT_HEX: +@@ -464,7 +464,7 @@ static int PTRCALL + PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) + { +- if (ptr != end) { ++ if (ptr < end) { + if (CHAR_MATCHES(enc, ptr, ASCII_x)) + return PREFIX(scanHexCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); + switch (BYTE_TYPE(enc, ptr)) { +@@ -474,7 +474,7 @@ PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } +- for (ptr += MINBPC(enc); ptr != end; ptr += MINBPC(enc)) { ++ for (ptr += MINBPC(enc); ptr < end; ptr += MINBPC(enc)) { + switch (BYTE_TYPE(enc, ptr)) { + case BT_DIGIT: + break; +@@ -506,7 +506,7 @@ PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end, + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) + case BT_SEMI: +@@ -529,7 +529,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end, + #ifdef XML_NS + int hadColon = 0; + #endif +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) + #ifdef XML_NS +@@ -716,7 +716,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end, + hadColon = 0; + #endif + /* we have a start-tag */ +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) + #ifdef XML_NS +@@ -740,7 +740,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end, + case BT_S: case BT_CR: case BT_LF: + { + ptr += MINBPC(enc); +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) + case BT_GT: +@@ -785,7 +785,7 @@ static int PTRCALL + PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end, + const char **nextTokPtr) + { +- if (ptr == end) ++ if (ptr >= end) + return XML_TOK_NONE; + if (MINBPC(enc) > 1) { + size_t n = end - ptr; +@@ -832,7 +832,7 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end, + ptr += MINBPC(enc); + break; + } +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + #define LEAD_CASE(n) \ + case BT_LEAD ## n: \ +@@ -895,7 +895,7 @@ PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end, + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) + case BT_SEMI: +@@ -921,7 +921,7 @@ PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end, + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) + case BT_CR: case BT_LF: case BT_S: +@@ -941,7 +941,7 @@ PREFIX(scanLit)(int open, const ENCODING *enc, + const char *ptr, const char *end, + const char **nextTokPtr) + { +- while (ptr != end) { ++ while (ptr < end) { + int t = BYTE_TYPE(enc, ptr); + switch (t) { + INVALID_CASES(ptr, nextTokPtr) +@@ -973,7 +973,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, + const char **nextTokPtr) + { + int tok; +- if (ptr == end) ++ if (ptr >= end) + return XML_TOK_NONE; + if (MINBPC(enc) > 1) { + size_t n = end - ptr; +@@ -1141,7 +1141,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) + case BT_GT: case BT_RPAR: case BT_COMMA: +@@ -1204,10 +1204,10 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) + { + const char *start; +- if (ptr == end) ++ if (ptr >= end) + return XML_TOK_NONE; + start = ptr; +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + #define LEAD_CASE(n) \ + case BT_LEAD ## n: ptr += n; break; +@@ -1262,10 +1262,10 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) + { + const char *start; +- if (ptr == end) ++ if (ptr >= end) + return XML_TOK_NONE; + start = ptr; +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + #define LEAD_CASE(n) \ + case BT_LEAD ## n: ptr += n; break; +@@ -1326,7 +1326,7 @@ PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, + end = ptr + n; + } + } +- while (ptr != end) { ++ while (ptr < end) { + switch (BYTE_TYPE(enc, ptr)) { + INVALID_CASES(ptr, nextTokPtr) + case BT_LT: +@@ -1373,7 +1373,7 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, + { + ptr += MINBPC(enc); + end -= MINBPC(enc); +- for (; ptr != end; ptr += MINBPC(enc)) { ++ for (; ptr < end; ptr += MINBPC(enc)) { + switch (BYTE_TYPE(enc, ptr)) { + case BT_DIGIT: + case BT_HEX: +@@ -1760,7 +1760,7 @@ PREFIX(updatePosition)(const ENCODING *enc, + case BT_CR: + pos->lineNumber++; + ptr += MINBPC(enc); +- if (ptr != end && BYTE_TYPE(enc, ptr) == BT_LF) ++ if (ptr < end && BYTE_TYPE(enc, ptr) == BT_LF) + ptr += MINBPC(enc); + pos->columnNumber = (XML_Size)-1; + break; +-- +2.8.2 + -- cgit v1.2.3