fix bug # readLength

fix bugs: when maxLength is 0 or -1, ignore it and do not compare with length