> It's terribly non-obvious how to deal with correctly.
Like the post says: read the whole thing into memory and do a reverse search for the last ')', i.e. strrchr
Once you are aware of the problem, it's obvious how to solve it, but I do agree that the hidden danger here is not immediately obvious at first.