-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-37090][BUILD] Upgrade libthrift to 0.16.0 to avoid security vulnerabilities
#34362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8d108ad
Backport HIVE-21498
wangyum d0e7777
Remove javax.annotation-api
wangyum 017f937
0.16.0
wangyum c7d6c6a
Merge branch 'apache:master' into SPARK-37090
wangyum ccc25d0
Port HIVE-25098
wangyum 476958f
Init
wangyum 442f9a3
Workaround:
wangyum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
200 changes: 200 additions & 0 deletions
200
sql/hive/src/main/java/org/apache/thrift/transport/TFramedTransport.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,200 @@ | ||
| /* | ||
| * 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.thrift.transport; | ||
|
|
||
|
|
||
| import org.apache.thrift.TByteArrayOutputStream; | ||
| import org.apache.thrift.TConfiguration; | ||
|
|
||
| /** | ||
| * This is based on libthrift-0.12.0 {@link org.apache.thrift.transport.TFramedTransport}. | ||
| * To fix class of org.apache.thrift.transport.TFramedTransport not found after upgrading libthrift. | ||
| * | ||
| * TFramedTransport is a buffered TTransport that ensures a fully read message | ||
| * every time by preceding messages with a 4-byte frame size. | ||
| */ | ||
|
Comment on lines
+25
to
+30
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| public class TFramedTransport extends TTransport { | ||
|
|
||
| protected static final int DEFAULT_MAX_LENGTH = 16384000; | ||
|
|
||
| private int maxLength_; | ||
|
|
||
| /** | ||
| * Underlying transport | ||
| */ | ||
| private TTransport transport_ = null; | ||
|
|
||
| /** | ||
| * Buffer for output | ||
| */ | ||
| private final TByteArrayOutputStream writeBuffer_ = | ||
| new TByteArrayOutputStream(1024); | ||
|
|
||
| /** | ||
| * Buffer for input | ||
| */ | ||
| private final TMemoryInputTransport readBuffer_ = | ||
| new TMemoryInputTransport(new byte[0]); | ||
|
|
||
| public static class Factory extends TTransportFactory { | ||
| private int maxLength_; | ||
|
|
||
| public Factory() { | ||
| maxLength_ = TFramedTransport.DEFAULT_MAX_LENGTH; | ||
| } | ||
|
|
||
| public Factory(int maxLength) { | ||
| maxLength_ = maxLength; | ||
| } | ||
|
|
||
| @Override | ||
| public TTransport getTransport(TTransport base) throws TTransportException { | ||
| return new TFramedTransport(base, maxLength_); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Constructor wraps around another transport | ||
| */ | ||
| public TFramedTransport(TTransport transport, int maxLength) throws TTransportException { | ||
| transport_ = transport; | ||
| maxLength_ = maxLength; | ||
| } | ||
|
|
||
| public TFramedTransport(TTransport transport) throws TTransportException { | ||
| transport_ = transport; | ||
| maxLength_ = TFramedTransport.DEFAULT_MAX_LENGTH; | ||
| } | ||
|
|
||
| public void open() throws TTransportException { | ||
| transport_.open(); | ||
| } | ||
|
|
||
| public boolean isOpen() { | ||
| return transport_.isOpen(); | ||
| } | ||
|
|
||
| public void close() { | ||
| transport_.close(); | ||
| } | ||
|
|
||
| public int read(byte[] buf, int off, int len) throws TTransportException { | ||
| int got = readBuffer_.read(buf, off, len); | ||
| if (got > 0) { | ||
| return got; | ||
| } | ||
|
|
||
| // Read another frame of data | ||
| readFrame(); | ||
|
|
||
| return readBuffer_.read(buf, off, len); | ||
| } | ||
|
|
||
| @Override | ||
| public byte[] getBuffer() { | ||
| return readBuffer_.getBuffer(); | ||
| } | ||
|
|
||
| @Override | ||
| public int getBufferPosition() { | ||
| return readBuffer_.getBufferPosition(); | ||
| } | ||
|
|
||
| @Override | ||
| public int getBytesRemainingInBuffer() { | ||
| return readBuffer_.getBytesRemainingInBuffer(); | ||
| } | ||
|
|
||
| @Override | ||
| public void consumeBuffer(int len) { | ||
| readBuffer_.consumeBuffer(len); | ||
| } | ||
|
|
||
| @Override | ||
| public TConfiguration getConfiguration() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public void updateKnownMessageSize(long l) throws TTransportException { | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public void checkReadBytesAvailable(long l) throws TTransportException { | ||
|
|
||
| } | ||
|
|
||
| public void clear() { | ||
| readBuffer_.clear(); | ||
| } | ||
|
|
||
| private final byte[] i32buf = new byte[4]; | ||
|
|
||
| private void readFrame() throws TTransportException { | ||
| transport_.readAll(i32buf, 0, 4); | ||
| int size = decodeFrameSize(i32buf); | ||
|
|
||
| if (size < 0) { | ||
| close(); | ||
| throw new TTransportException(TTransportException.CORRUPTED_DATA, | ||
| "Read a negative frame size (" + size + ")!"); | ||
| } | ||
|
|
||
| if (size > maxLength_) { | ||
| close(); | ||
| throw new TTransportException(TTransportException.CORRUPTED_DATA, | ||
| "Frame size (" + size + ") larger than max length (" + maxLength_ + ")!"); | ||
| } | ||
|
|
||
| byte[] buff = new byte[size]; | ||
| transport_.readAll(buff, 0, size); | ||
| readBuffer_.reset(buff); | ||
| } | ||
|
|
||
| public void write(byte[] buf, int off, int len) throws TTransportException { | ||
| writeBuffer_.write(buf, off, len); | ||
| } | ||
|
|
||
| @Override | ||
| public void flush() throws TTransportException { | ||
| byte[] buf = writeBuffer_.get(); | ||
| int len = writeBuffer_.len(); | ||
| writeBuffer_.reset(); | ||
|
|
||
| encodeFrameSize(len, i32buf); | ||
| transport_.write(i32buf, 0, 4); | ||
| transport_.write(buf, 0, len); | ||
| transport_.flush(); | ||
| } | ||
|
|
||
| public static final void encodeFrameSize(final int frameSize, final byte[] buf) { | ||
| buf[0] = (byte)(0xff & (frameSize >> 24)); | ||
| buf[1] = (byte)(0xff & (frameSize >> 16)); | ||
| buf[2] = (byte)(0xff & (frameSize >> 8)); | ||
| buf[3] = (byte)(0xff & (frameSize)); | ||
| } | ||
|
|
||
| public static final int decodeFrameSize(final byte[] buf) { | ||
| return | ||
| ((buf[0] & 0xff) << 24) | | ||
| ((buf[1] & 0xff) << 16) | | ||
| ((buf[2] & 0xff) << 8) | | ||
| ((buf[3] & 0xff)); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.