-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
What steps will reproduce the problem?
1. create a message payload with multi-byte text, over the maximum amount of
characters allowed for the message (512 bytes)
2. try to send it
What is the expected output? What do you see instead?
com.googlecode.jsendnsca.NagiosException: Error occurred while sending passive
alert
at com.googlecode.jsendnsca.NagiosPassiveCheckSender.send(NagiosPassiveCheckSender.java:95)
at com.gsm.nsca.Alerter$AlertSender.process(Alerter.java:553)
at com.gsm.lib.BatchRunner.processElements(BatchRunner.java:316)
at com.gsm.lib.BatchRunner.flushBatch(BatchRunner.java:164)
at com.gsm.lib.BatchRunner.run(BatchRunner.java:87)
Caused By: java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at com.googlecode.jsendnsca.utils.ByteArrayUtils.getFixedSizeBytes(ByteArrayUtils.java:98)
at com.googlecode.jsendnsca.utils.ByteArrayUtils.writeFixedString(ByteArrayUtils.java:44)
at com.googlecode.jsendnsca.PassiveCheckBytesBuilder.writeFixedString(PassiveCheckBytesBuilder.java:88)
at com.googlecode.jsendnsca.PassiveCheckBytesBuilder.withMessage(PassiveCheckBytesBuilder.java:61)
at com.googlecode.jsendnsca.NagiosPassiveCheckSender.send(NagiosPassiveCheckSender.java:80)
at com.gsm.nsca.Alerter$AlertSender.process(Alerter.java:553)
at com.gsm.lib.BatchRunner.processElements(BatchRunner.java:316)
at com.gsm.lib.BatchRunner.flushBatch(BatchRunner.java:164)
at com.gsm.lib.BatchRunner.run(BatchRunner.java:87)
What version of the product are you using? On what operating system?
2.0.1
Please provide any additional information below.
ByteArratUtils.getFixedSizeBytes() is broken.
At first, it uses character length to cap the string to maximum bytes allowed,
but then uses byte length to copy the string into the array.
Considering that it would be as bad to convert the string into the array, and
then cut it (as it can cut through a multi-byte character), it may be best to
estimate using the character length first, and then keep dropping characters
from the end until the byte length is satisfied. I don't know of any tricks
that would make it more efficient.
Original issue reported on code.google.com by pawel.ve...@gmail.com on 27 Feb 2014 at 6:58
Reactions are currently unavailable