Skip to content

Tight encoding with zlib compression level 0 (uncompressed) #370

Description

@PT2020-cd

When using Tight encoding with zlib compression level 0 (uncompressed), the libvncserver is bypassing the zlib compression and sending the uncompressed buffer. This is not working on clients UltraVNCViewer and TightVNC. Solution: compress the buffer with zlib level 0 before sending the data. The difference is that the zlib header will be attached before the buffer even if there is no compression.

Following lines have to be removed in libvncserver/tight.c (I set them in comment):

SendMonoRect:

    dataLen = (w + 7) / 8;
    dataLen *= h;

/*    if (tightConf[compressLevel].monoZlibLevel == 0 &&
        cl->tightEncoding != rfbEncodingTightPng)
        cl->updateBuf[cl->ublen++] =
            (char)((rfbTightNoZlib | rfbTightExplicitFilter) << 4);
    else
*/        cl->updateBuf[cl->ublen++] = (streamId | rfbTightExplicitFilter) << 4;
    cl->updateBuf[cl->ublen++] = rfbTightFilterPalette;
    cl->updateBuf[cl->ublen++] = 1;

SendIndexedRect:

    /* Prepare tight encoding header. */
/*    if (tightConf[compressLevel].idxZlibLevel == 0 &&  cl->tightEncoding != rfbEncodingTightPng) {
    	cl->updateBuf[cl->ublen++] =
            (char)((rfbTightNoZlib | rfbTightExplicitFilter) << 4);
    } else
*/        cl->updateBuf[cl->ublen++] = (streamId | rfbTightExplicitFilter) << 4;
    cl->updateBuf[cl->ublen++] = rfbTightFilterPalette;
    cl->updateBuf[cl->ublen++] = (char)(paletteNumColors - 1);

SendFullColorRect:

    if (cl->ublen + TIGHT_MIN_TO_COMPRESS + 1 > UPDATE_BUF_SIZE) {
        if (!rfbSendUpdateBuf(cl))
            return FALSE;
    }

/*    if (tightConf[compressLevel].rawZlibLevel == 0 &&
        cl->tightEncoding != rfbEncodingTightPng)
        cl->updateBuf[cl->ublen++] = (char)(rfbTightNoZlib << 4);
    else
*/        cl->updateBuf[cl->ublen++] = 0x00;  /* stream id = 0, no flushing, no filter */
    rfbStatRecordEncodingSentAdd(cl, cl->tightEncoding, 1);

CompressData:

/*    if (zlibLevel == 0) {
    	printf("VNC: UnComp %i\n",dataLen);
        return rfbSendCompressedDataTight(cl, tightBeforeBuf, dataLen);
    }
*/
    pz = &cl->zsStruct[streamId];

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions