Menu

Fix for OCI_LobSeek

2014-04-11
2014-06-14
  • Albertino80

    Albertino80 - 2014-04-11

    Hi,
    i found a bug in function:
    boolean OCI_API OCI_LobSeek

    the problem is related to the control:
    if ((offset + lob->offset - 1) > size)
    that is valid only if mode = OCI_SEEK_CUR

    I changed the function (see below), now it works properly.

    boolean OCI_API OCI_LobSeek
    (
        OCI_Lob     *lob,
        big_uint     offset,
        unsigned int mode
    )
    {
        boolean res   = TRUE;
        big_uint size = 0;
    
        OCI_CHECK_PTR(OCI_IPC_LOB, lob, FALSE);
    
        size = OCI_LobGetLength(lob);
    
        switch (mode)
        {
            case OCI_SEEK_CUR:
                if ((offset + lob->offset - 1) > size) 
                    res = FALSE;
                else
                    lob->offset += offset;
                break;
            case OCI_SEEK_SET:
                if (offset > size) 
                    res = FALSE;
                else
                    lob->offset = offset + 1;
                break;
            case OCI_SEEK_END:
                if (offset > size) 
                    res = FALSE;
                else
                    lob->offset = size - offset + 1;
                break;
            default:
                res = FALSE;
        }
    
        OCI_RESULT(res);
    
        return res;
    }
    
     
  • Vincent Rogier

    Vincent Rogier - 2014-06-14

    Bug fixed in OCILIB trunck (v4.0.0)