Thread (19 messages) flat view 19 messages, 1 author, 2016-06-15
DORMANTno replies

[EGIT PATCH 02/26] Protect WorkingTreeIterator's name encoding from weird ByteBuffers

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:45:08
Subsystem: the rest · Maintainer: Linus Torvalds

If a ByteBuffer decides to be cute and give us an array but use
an array offset that isn't zero we cannot use its array as our
own encodedName array.  Instead we must create a copy of the array
so we can safely assume where the path starts.

Signed-off-by: Shawn O. Pearce <redacted>
---
 .../spearce/jgit/treewalk/WorkingTreeIterator.java |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
index 4ac711b..356222b 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
@@ -415,7 +415,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
 				throws CharacterCodingException {
 			final ByteBuffer b = enc.encode(CharBuffer.wrap(getName()));
 			encodedNameLen = b.limit();
-			if (b.hasArray())
+			if (b.hasArray() && b.arrayOffset() == 0)
 				encodedName = b.array();
 			else
 				b.get(encodedName = new byte[encodedNameLen]);
-- 
1.6.0.rc2.22.g71b99
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help