Hacker News new | ask | show | jobs
by jhatax 16 days ago
For what it is worth, the code block that precedes this one is an if-condition that has a call to apr_table_setn with as `r` vs. req as the first parameter. This could very well be a case of a developer missing one code block. It could also be that the repo's compiler settings aren't strict enough to flag this as an issue -> writing to a const.

Where this is one such oversight, there are likely others. An LLM isn't needed to find these, likely stricter compiler flags.

2 comments

Here's the commit from 4 years ago that refactored the code into its current state:

https://github.com/icing/mod_h2/commit/1b468851c89cdbf6d0f98...

Looks like he made the change on the Transfer-Encoding line when he was moving things around, but missed doing the same on the Content-Length line.

I don't believe C's const catches this regardless of compiler settings. What's disallowed by const here is `req->header = x`, but the type of `req->header` is a pointer, which is not const. The constness of pointers is not transitive like that. By contrast, in Rust: `t.u` when `t` is `&T`, is `&U`.