ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/3] incubator-ignite git commit: ignite-471: fixed buffer overflow exception in optimizedmarshaller
Date Thu, 14 May 2015 13:28:24 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-471 505dc6286 -> 1f021a734


ignite-471: fixed buffer overflow exception in optimizedmarshaller


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/887cb015
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/887cb015
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/887cb015

Branch: refs/heads/ignite-471
Commit: 887cb01544555e506f34ac69196e3cd83296f9d7
Parents: 505dc62
Author: Denis Magda <dmagda@gridgain.com>
Authored: Thu May 14 09:54:53 2015 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Thu May 14 09:54:53 2015 +0300

----------------------------------------------------------------------
 .../GridClientOptimizedMarshaller.java          |  2 +-
 .../optimized/OptimizedMarshaller.java          | 22 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/887cb015/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
b/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
index ff77177..9fd6bbc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
@@ -67,7 +67,7 @@ public class GridClientOptimizedMarshaller implements GridClientMarshaller
{
                 throw new IOException("Message serialization of given type is not supported:
" +
                     obj.getClass().getName());
 
-            return opMarsh.marshal(obj);
+            return opMarsh.marshal(obj, off);
         }
         catch (IgniteCheckedException e) {
             throw new IOException(e);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/887cb015/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
index a29bda2..28433ec 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
@@ -172,6 +172,18 @@ public class OptimizedMarshaller extends AbstractMarshaller {
 
     /** {@inheritDoc} */
     @Override public ByteBuffer marshal(@Nullable Object obj) throws IgniteCheckedException
{
+        return marshal(obj, 0);
+    }
+
+    /**
+     * Marshals object to bytes.
+     *
+     * @param obj Object to marshal.
+     * @param offset Position where to start marshalling the object.
+     * @return Byte buffer.
+     * @throws IgniteCheckedException If marshalling failed.
+     */
+    public ByteBuffer marshal(@Nullable Object obj, int offset) throws IgniteCheckedException
{
         OptimizedObjectOutputStream objOut = null;
 
         try {
@@ -182,7 +194,15 @@ public class OptimizedMarshaller extends AbstractMarshaller {
 
             objOut.writeObject(obj);
 
-            return ByteBuffer.wrap(objOut.out().internalArray(), 0, objOut.out().offset());
+            ByteBuffer buffer = ByteBuffer.allocate(objOut.out().offset() + offset);
+
+            buffer.position(offset);
+
+            buffer.put(objOut.out().internalArray(), 0, objOut.out().offset());
+
+            buffer.flip();
+
+            return buffer;
         }
         catch (IOException e) {
             throw new IgniteCheckedException("Failed to serialize object: " + obj, e);


Mime
View raw message