You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2021/12/13 21:41:15 UTC

[GitHub] [logging-log4j2] jyemin commented on a change in pull request #618: Check javaClassName before JNDI lookup

jyemin commented on a change in pull request #618:
URL: https://github.com/apache/logging-log4j2/pull/618#discussion_r768143664



##########
File path: log4j-core/src/main/java/org/apache/logging/log4j/core/net/SerializationHelper.java
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net;
+
+import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+
+import static java.io.ObjectStreamConstants.STREAM_MAGIC;
+import static java.io.ObjectStreamConstants.STREAM_VERSION;
+import static java.io.ObjectStreamConstants.TC_ARRAY;
+import static java.io.ObjectStreamConstants.TC_CLASS;
+import static java.io.ObjectStreamConstants.TC_CLASSDESC;
+import static java.io.ObjectStreamConstants.TC_ENUM;
+import static java.io.ObjectStreamConstants.TC_LONGSTRING;
+import static java.io.ObjectStreamConstants.TC_OBJECT;
+import static java.io.ObjectStreamConstants.TC_PROXYCLASSDESC;
+import static java.io.ObjectStreamConstants.TC_REFERENCE;
+import static java.io.ObjectStreamConstants.TC_STRING;
+
+// See https://docs.oracle.com/javase/7/docs/platform/serialization/spec/protocol.html for
+// specification of the Object Serialization Stream Protocol
+final class SerializationHelper {
+    // Return the class name of serializedObject, or null if the class name can not be extracted.
+    static String extractClassName(final byte[] serializedObject) {

Review comment:
       The tests show otherwise.  This is just a sanity check that the byte array actually represents a serialized object, which is required to start with STREAM_MAGIC and STREAM_VERSION, in sequence.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org