arduino / ArduinoCore-mbed

347 stars 203 forks source link

Potential http parser defect due to case fallthrough? #999

Closed schnoberts1 closed 1 week ago

schnoberts1 commented 1 week ago

Hi,

While removing a lot of warnings from ArduinoCore-mbed I noticed this code in http_parser.c:

         switch (settings->on_headers_complete(parser)) {
            case 0:
              break;

            case 2:
              parser->upgrade = 1;

            case 1:
              parser->flags |= F_SKIPBODY;
              break;

            default:
              SET_ERRNO(HPE_CB_headers_complete);
              RETURN(p - data); /* Error */
          }

case 2 falls through but unlike elsewhere in the codebase, it is not marked fall through so perhaps this is a defect? I'm not familiar with this code so I have no opinion, just thought I'd raise it.

pennam commented 1 week ago

not an expert too, but in other repos is marked as fallthrough, so it should be ok! https://github.com/nodejs/http-parser/blob/ec8b5ee63f0e51191ea43bb0c6eac7bfbff3141d/http_parser.c#L1856