buffer add length check
modify api
Merge pull request #36 from ewenlaz/master

add package length check