Fix: JSON-RPC param reader overshoots trailing delimiter, breaking append (#828)#829
Fix: JSON-RPC param reader overshoots trailing delimiter, breaking append (#828)#829selmant wants to merge 1 commit into
Conversation
…pend (nzbgetcom#828) The JSON branches of NextParamAsInt/Bool/Str advanced m_requestPtr by "+ len + 1", skipping the value plus an assumed "," separator. For the final element of the params array that delimiter is "]", so the cursor leaked past it into the rest of the request (e.g. ,"id":1}). On the v13 append path the PP-Parameters loop then read the request's "id" field as a parameter and rejected the call with "Invalid parameter (Parameters)" — so append failed whenever a field followed "params" in the envelope. Advance to "+ len" instead and let JsonNextValue's existing leading-separator skip consume the delimiter on the next read. This matches how tests/util/Util.cpp already steps the helper (keyPtr + length). The XML-RPC and HTTP-GET branches are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@selmant Hello, I can create test builds from my branch so you can test them on your end. I’ve verified the fix for my case but can’t guarantee it will work with |
Description
Fixes #828.
The JSON branches of
XmlCommand::NextParamAsInt/Bool/Stradvancem_requestPtrby+ len + 1, skipping the value plus an assumed,separator. For the final element of the params array that delimiter is], so the cursor lands past it — inside the rest of the request (e.g.,"id":1}).On the
v13appendpath the PP-Parametersloop (while (NextParamAsStr(¶mName))) then reads the request's"id"field as a parameter name and rejects the call withInvalid parameter (Parameters). The result: a JSON-RPCappendwith base64 content fails whenever any field follows"params"in the envelope (i.e. almost always), while it "works" if"params"happens to be last.editqueueis unaffected only because its trailing nested]]absorbs the overshoot.This is complementary to #702 (which fixed
JsonNextValuenesting inUtil.cpp); the over-advance is in the readers and was untouched by it. Still present ondevelop.Fix
Advance to
+ len(the value's delimiter) and letJsonNextValue's existing leading-separator skip (" ,[{:\r\n\t\f") consume it on the next read. For the last element the cursor then rests on], which the readers correctly treat as end-of-array.This matches how the existing tests already step the helper —
tests/util/Util.cppusesJsonNextValue(keyPtr + length, ...)(no+ 1). The XML-RPC and HTTP-GET branches are unchanged.Verification
I reproduced the parser with a faithful port of
JsonNextValue+ the three readers and confirmed:append(v13,idafterparams)editqueue(nested array)+ len + 1)Invalid parameter (Parameters)+ len)Also confirmed live against NZBGet 26.1: the same
appendthat returnedInvalid parameter (Parameters)now succeeds and returns the NZBID.Notes for reviewers
XmlCommand::NextParamAs*today (tests/remote/doesn't exist), so I didn't add a reader-level regression test. Happy to add one (or a harness) if you'd like — guidance on the preferred location welcome.Testing