Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chunk type is restricted to the decimal values 65 to 90 and 97 to 122 #181

Open
boofish opened this issue Jun 9, 2023 · 0 comments
Open

Comments

@boofish
Copy link

boofish commented Jun 9, 2023

Hi, according to the specification, chunk type is restricted to the decimal values 65 to 90 and 97 to 122.

Maybe this could be fixed at the function decodeGeneric by replacing

else /*it's not an implemented chunk type, so ignore it: skip over the data*/ {
      /*error: unknown critical chunk (5th bit of first byte of chunk type is 0)*/
      if(!state->decoder.ignore_critical && !lodepng_chunk_ancillary(chunk)) {
        CERROR_BREAK(state->error, 69);
      }

with

else /*it's not an implemented chunk type, so ignore it: skip over the data*/ {
      /*error: unknown critical chunk (5th bit of first byte of chunk type is 0)*/
      unsigned i;
      for(i = 0; i != 4; ++i) 
        if (!((chunk[i+4]>='a' && chunk[i+4]<='z') || (chunk[i+4]>='A' && chunk[i+4]<='Z'))) {
            CERROR_BREAK(state->error, 116); // invalid chunk type
        }
      if(!state->decoder.ignore_critical && !lodepng_chunk_ancillary(chunk)) {
        CERROR_BREAK(state->error, 69);
      }

This rule is meaningful and it can allow safe, flexible extension of the PNG format according to the specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant