This project is read-only.

Bug in _opcZipFileRead

Mar 10, 2014 at 2:48 PM
There appears to be a bug in _opcZipFileRead() in zip.c.
static inline opc_uint32_t _opcZipFileRead(opcIO_t *io, opc_uint8_t *buf, opc_uint32_t buf_len) {
    OPC_ASSERT(NULL!=io && io->_ioread!=NULL && NULL!=buf);
    opc_uint32_t ret=0;
    if (OPC_ERROR_NONE==io->state.err) {
        int len=io->_ioread(io->iocontext, (char *)buf, buf_len);
        if (ret<0) {
        } else {
    return ret;
The test of: if (ret<0) will always be false since ret is initialized to zero. Also, ret us unsigned so it's impossible to be < 0.

I assume the test should be: if (len < 0) though in that case, ret will be zero; is that the desired return code for an error?

Mar 10, 2014 at 2:51 PM
Ah yes, I see this is reported in the issues with an attached fix. Should have checked there first.
Mar 10, 2014 at 2:53 PM
But the fix is still not correct... it's casting len to (opc_uint32_t) which cannot be < 0.