Opened 6 years ago

Closed 6 years ago

#1603 closed defect (fixed)


Reported by: user Owned by: str4d
Priority: minor Milestone: 0.9.23
Component: apps/plugins Version: 0.9.20
Keywords: I2P-Bote Cc:
Parent Tickets: Sensitive: no


I sometimes get 0 size files and those trigger errors liek this one:

6/12/15 4:11:39 PM ERROR [ExpiratnThrd?] i2p.bote.folder.Folder : Can't create a FolderElement? from file: /path/to/.i2p/i2pbote/dht_index_pkt/nW6uWINdi~5TqZKzkG~YhzLf8evLrF0IWkqHpR091Rg=.pkt (file size=0)

java.lang.ArrayIndexOutOfBoundsException?: 0
at i2p.bote.packet.CommunicationPacket?.isPrefixValid(CommunicationPacket?.java:122)
at i2p.bote.packet.I2PBotePacket.createPacket(
at i2p.bote.packet.I2PBotePacket.createPacket(
at i2p.bote.folder.PacketFolder?.createFolderElement(PacketFolder?.java:85)
at i2p.bote.folder.PacketFolder?.createFolderElement(PacketFolder?.java:42)
at i2p.bote.folder.Folder$3.findNextElement(
at i2p.bote.folder.Folder$
at i2p.bote.folder.PacketFolder?$
at i2p.bote.folder.PacketFolder?$
at i2p.bote.folder.IndexPacketFolder?.deleteExpired(IndexPacketFolder?.java:99)
at i2p.bote.service.ExpirationThread?.run(ExpirationThread?.java:53)


Change History (4)

comment:1 Changed 6 years ago by zzz

Component: otherapps/plugins
Owner: set to str4d
Status: newassigned

comment:2 Changed 6 years ago by kay

In order to prevent this IAOOBE and a possible NPE check for null and packet array length.

# old_revision [0d6505d2805dff9774d816a899b6463074057c15]
# patch "src/main/java/i2p/bote/packet/"
#  from [bb37a2da9cb08fdc7656f3daf0d17e3e4c008c0f]
#    to [53b933a1f8fb872af0e0d95929509f51ac9eb456]
--- src/main/java/i2p/bote/packet/	bb37a2da9cb08fdc7656f3daf0d17e3e4c008c0f
+++ src/main/java/i2p/bote/packet/	53b933a1f8fb872af0e0d95929509f51ac9eb456
@@ -118,6 +118,8 @@ public abstract class CommunicationPacke
      * @param packet
     static boolean isPrefixValid(byte[] packet) {
+        if(null == packet || packet.length < PACKET_PREFIX.length)
+            return false;
         for (int i=0; i<PACKET_PREFIX.length; i++)
             if (packet[i] != PACKET_PREFIX[i])
                 return false;

comment:3 Changed 6 years ago by kay

Keywords: I2P-Bote needs_review added

comment:4 Changed 6 years ago by str4d

Keywords: needs_review removed
Milestone: undecided0.9.23
Resolution: fixed
Status: assignedclosed

Fixes in 6b51a1f56403aeddc800bccf982181cebb65beae.

Note: See TracTickets for help on using tickets.