fixed problem when packet length is greater than buffer size.