Skip to content

[sinfl] The sinfl_write_128 function wrote 16 bytes but only shifted by 8 bytes #62

@yixy-only

Description

@yixy-only

In <sinfl.h>, the code of the sinfl_write_128 function is as follows:

static unsigned char*
sinfl_write128(unsigned char *dst, sinfl_char16 w) {
  sinfl_char16_str(dst, w);
  return dst + 8;
}

The return value should be dst + 16.

It merely moved 8 bytes. This movement will only affect performance but will not impact the calculation results, as this function is only used for batch copying of bytes.

However, I'm not sure if directly making the modification would cause an out-of-bounds access. Has sufficient space been reserved in the buffer?

The code that uses the aforementioned function is as follows in <sinfl.h>:

else if (offs == 1) {
    /* rle match copying */
    sinfl_char16 w = sinfl_char16_char(src[0]);
    dst = sinfl_write128(dst, w);
    dst = sinfl_write128(dst, w);
    do dst = sinfl_write128(dst, w);
    while (dst < out);
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions