Skip to content

Commit d7d77df

Browse files
committed
[SYSTEMDS-3282] Upper bound for number of decoders
This patch adds a coherence check on the number of deserialized decoders in DecoderComposite object. Closes #1527.
1 parent ada4706 commit d7d77df

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/org/apache/sysds/runtime/transform/decode/DecoderComposite.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public void initMetaData(FrameBlock meta) {
8383
public void writeExternal(ObjectOutput out) throws IOException {
8484
super.writeExternal(out);
8585
out.writeInt(_decoders.size());
86+
out.writeInt(_schema == null ? 0:_schema.length); //write #columns
8687
for(Decoder decoder : _decoders) {
8788
out.writeByte(DecoderFactory.getDecoderType(decoder));
8889
decoder.writeExternal(out);
@@ -93,6 +94,9 @@ public void writeExternal(ObjectOutput out) throws IOException {
9394
public void readExternal(ObjectInput in) throws IOException {
9495
super.readExternal(in);
9596
int decodersSize = in.readInt();
97+
int nCols = in.readInt();
98+
if (nCols > 0 && decodersSize > nCols*2)
99+
throw new IOException("Too many decoders");
96100
_decoders = new ArrayList<>();
97101
for(int i = 0; i < decodersSize; i++) {
98102
Decoder decoder = DecoderFactory.createInstance(in.readByte());

0 commit comments

Comments
 (0)