2014-11-17 5 views
1

iTextSharp의 zlib 구현에서 매우 심각한 성가신 문제를 발견했습니다. 그것은 PDF로가는 실제 데이터에 있지만, 일부 상황에서 의존하기 때문에 재현 할 매우 어려운, 다음과 같은 예외가 발생합니다iTextSharp의 zlib 압축에서 IndexOutOfRangeException이 발생했습니다.

System.util.zlib.Tree.cs에서
System.IndexOutOfRangeException: Index was outside the bounds of the array. 
at System.util.zlib.Tree.d_code(Int32 dist) 
at System.util.zlib.Deflate.compress_block(Int16[] ltree, Int16[] dtree) 

답변

2

은 분명히 어떤 범위 체크, 결코 잘못 않을 것들의 가정이 없다 . 다음 (byte) 캐스트를 추가하는 것이 해결책 인 것 같습니다.

internal static int d_code(int dist){ 
    return ((dist) < 256 ? _dist_code[dist] : _dist_code[256+(byte)((dist)>>7)]); 
}