Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Unified Diff: third_party/libxslt/libxslt/transform.c

Issue 2626983002: Check for overflow when merging text nodes. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libxslt/README.chromium ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libxslt/libxslt/transform.c
diff --git a/third_party/libxslt/libxslt/transform.c b/third_party/libxslt/libxslt/transform.c
index b3fce80aade12a9a1e7eba718d0cc66b60e6412c..c82f6782caf94002b804f00c4893aea9bd2c1a3f 100644
--- a/third_party/libxslt/libxslt/transform.c
+++ b/third_party/libxslt/libxslt/transform.c
@@ -820,12 +820,12 @@ xsltAddTextString(xsltTransformContextPtr ctxt, xmlNodePtr target,
if (ctxt->lasttuse + len >= ctxt->lasttsize) {
xmlChar *newbuf;
- int size;
+ size_t size;
size = ctxt->lasttsize + len + 100;
size *= 2;
newbuf = (xmlChar *) xmlRealloc(target->content,size);
- if (newbuf == NULL) {
+ if (newbuf == NULL || size < ctxt->lasttsize) {
scottmg 2017/01/11 17:46:07 This is intended to be an overflow check, or? (nom
scottmg 2017/01/11 18:02:23 (Er, * 2 above obviously) I guess on x86 it might
xsltTransformError(ctxt, NULL, target,
"xsltCopyText: text allocation failed\n");
return(NULL);
@@ -834,6 +834,11 @@ xsltAddTextString(xsltTransformContextPtr ctxt, xmlNodePtr target,
ctxt->lasttext = newbuf;
target->content = newbuf;
}
+ if (ctxt->lasttuse >= ctxt->lasttsize - len) {
scottmg 2017/01/11 17:46:07 nit; This indent looks odd in Rietveld, but maybe
+ xsltTransformError(ctxt, NULL, target,
+ "xsltCopyText: text allocation failed\n");
+ return(NULL);
+ }
memcpy(&(target->content[ctxt->lasttuse]), string, len);
ctxt->lasttuse += len;
target->content[ctxt->lasttuse] = 0;
« no previous file with comments | « third_party/libxslt/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698