-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add message length check logic #66
Conversation
|
||
int length = Snappy.uncompressedLength(data); | ||
if (length >= Parameter.MAX_MESSAGE_LENGTH) { | ||
throw new IOException("message is too big, len=" + length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest optimizing the exception information, it should also be that the message after decompression is too large.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two IOException can be merged into one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use P2pException MESSAGE_WITH_WRONG_LENGTH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified, the two checks cannot be combined, the length must be checked before decompression.
} | ||
return d2; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int length = Snappy.uncompressedLength(data);
byte[] d2 = null;
if(length < Parameter.MAX_MESSAGE_LENGTH){
d2 = Snappy.uncompress(data);
}
if(length >= MAX_MESSAGE_LENGTH || d2.length >= Parameter.MAX_MESSAGE_LENGTH){
throws P2pException;
}
No description provided.