sijms / go-ora

Pure go oracle client
MIT License
807 stars 174 forks source link

runtime error: slice bounds out of range [:-1] #587

Closed protamail closed 3 weeks ago

protamail commented 2 months ago

When periodically ping'ing oracle connection, I often get the out-of-range error, originating from sijms/go-ora/v2/network/data_packet.go line 88:

pck.buffer = pck.buffer[:len(pck.buffer)-1]
sijms commented 1 month ago

protection added for the code

if len(pck.buffer) > 1 {
    var err error
    if sessionCtx.AdvancedService.CryptAlgo != nil || sessionCtx.AdvancedService.HashAlgo != nil {
        pck.buffer = pck.buffer[:len(pck.buffer)-1]
    }
    if sessionCtx.AdvancedService.CryptAlgo != nil {
        pck.buffer, err = sessionCtx.AdvancedService.CryptAlgo.Decrypt(pck.buffer)
        if err != nil {
            return nil, err
        }
        tracer.LogPacket("Read packet (Decrypted): ", pck.buffer)
    }
    if sessionCtx.AdvancedService.HashAlgo != nil {
        pck.buffer, err = sessionCtx.AdvancedService.HashAlgo.Validate(pck.buffer)
        if err != nil {
            return nil, err
        }
    }
}

you can test it at last commit