Changeset 60c93f1 for core


Ignore:
Timestamp:
Jan 17, 2017 3:34:38 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
7311cf3
Parents:
a36083a
Message:

Client: Don't log error on datagram dissector fail (ticket #1915),
let the client do the logging.
Throw early if data too short

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/client/datagram/I2PDatagramDissector.java

    ra36083a r60c93f1  
    3232
    3333    private static final int DGRAM_BUFSIZE = 32768;
     34    private static final int MIN_DGRAM_SIZE = 387 + 40;
    3435
    3536    private final DSAEngine dsaEng = DSAEngine.getInstance();
     
    6970     */
    7071    public void loadI2PDatagram(byte[] dgram) throws DataFormatException {
    71         ByteArrayInputStream dgStream = new ByteArrayInputStream(dgram);
    7272        // set invalid(very important!)
    7373        this.valid = false;
     74        if (dgram.length < MIN_DGRAM_SIZE)
     75            throw new DataFormatException("repliable datagram too small: " + dgram.length);
     76
     77        ByteArrayInputStream dgStream = new ByteArrayInputStream(dgram);
    7478       
    7579        try {
     
    97101            }
    98102        } catch (IOException e) {
    99             Log log = I2PAppContext.getGlobalContext().logManager().getLog(I2PDatagramDissector.class);
    100             log.error("Error loading datagram", e);
     103            // let the application do the logging
     104            //Log log = I2PAppContext.getGlobalContext().logManager().getLog(I2PDatagramDissector.class);
     105            //log.error("Error loading datagram", e);
    101106            throw new DataFormatException("Error loading datagram", e);
    102107        //} catch(AssertionError e) {
Note: See TracChangeset for help on using the changeset viewer.