Skip to content

Commit bfd360a

Browse files
pavel-alayiText-CI
authored andcommitted
DataMatrix: check negative textSize
DEVSIX-1845 Autoported commit. Original commit hash: [2da3c495c]
1 parent ed0038e commit bfd360a

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

itext.tests/itext.barcodes.tests/itext/barcodes/BarcodeDataMatrixTest.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,19 @@ public virtual void Barcode13Test() {
247247
barcodeDataMatrix.SetCode(str, 0, str.Length + 1);
248248
}
249249
, NUnit.Framework.Throws.TypeOf<IndexOutOfRangeException>());
250+
;
251+
}
252+
253+
[NUnit.Framework.Test]
254+
public virtual void Barcode14Test() {
255+
NUnit.Framework.Assert.That(() => {
256+
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
257+
barcodeDataMatrix.SetWidth(18);
258+
barcodeDataMatrix.SetHeight(18);
259+
byte[] str = "AbcdFFghijklmnop".GetBytes();
260+
barcodeDataMatrix.SetCode(str, 0, -1);
261+
}
262+
, NUnit.Framework.Throws.TypeOf<IndexOutOfRangeException>());
250263
;
251264
}
252265
}

itext/itext.barcodes/itext/barcodes/BarcodeDataMatrix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public virtual int SetCode(byte[] text, int textOffset, int textSize) {
260260
if (textOffset < 0) {
261261
throw new IndexOutOfRangeException("" + textOffset);
262262
}
263-
if (textOffset + textSize > text.Length) {
263+
if (textOffset + textSize > text.Length || textOffset + textSize < 0) {
264264
throw new IndexOutOfRangeException("" + textSize);
265265
}
266266
int extCount;

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
87676a67d71abfbc51c3bfd903094dcc3e51239c
1+
2da3c495c82c4340ff22020ca6667372b8d314ee

0 commit comments

Comments
 (0)