Skip to content

fix(net): return oslNetPostForm's reply as a whole string - #164

Merged
dogo merged 1 commit into
masterfrom
fix/post-form-response
Nov 5, 2026
Merged

dogo merged 1 commit into
masterfrom
fix/post-form-response

Conversation

@dogo

@dogo dogo commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Summary

Found while doing #160: what oslNetPostForm hands back in response.

 oslNetPostForm(url, data, response, responsesize)
+  response[0] = '\0'                          # empty until read in full: empty on failure
   ... send, status 200 ...
-  sceHttpReadData(request, response, responsesize)    # one read, no terminator
+  while length < responsesize - 1:
+      n = sceHttpReadData(request, response + length, responsesize - 1 - length)
+      n < 0  → response[0] = '\0', error
+      n == 0 → end of reply
+      length += n
+  response[length] = '\0'
   return 1

A single read only returns what has arrived, so a reply longer than one packet came back cut and still counted as a success. A read error after the first packet went unnoticed. The buffer was never terminated, so a caller printing it read past its end.

Evidence

Host test_net, with a fake sceHttpReadData that returns at most 8 bytes per call (like packets). The buffer starts as 'x', so a missing terminator shows:

Case Before After
30-byte reply, 64-byte buffer not terminated 30 characters
100-byte reply, 16-byte buffer not terminated 15 characters, returns 1
empty reply not terminated ""
404 buffer untouched ""
read error after 12 bytes returned success error, ""

httpget in PPSSPP (real HTTP to server.py; /form replies with 20000 letters):

Case Before After
post reply, 32 KB buffer no terminator 20000 characters, in order
post reply, 100-byte buffer no terminator 99 characters
post to a 404 no terminator error, 0 characters

The existing httpget cases and all 7 host tests pass.

Merge Danger

Door: two-way.

Blast Radius: network

  • response now holds at most responsesize - 1 characters plus the terminator. A caller that relied on getting exactly responsesize bytes gets one fewer.
  • After a failed post, response is an empty string instead of whatever it held before.
  • The return value is unchanged (1 on success). A reply longer than the buffer is cut without any report.

oslNetPostForm read the reply with a single sceHttpReadData of up to
responsesize bytes. Nothing terminated it, so a caller treating it as a
string read past the buffer; and one read returns only what has arrived,
so a reply longer than a packet came back cut, as a success (a read
error after the first packet went unseen). On failure the buffer kept
whatever it held.

It now reads until the end or until responsesize - 1 bytes, and
terminates the reply; the reply is empty until read in full, so it is
empty when the post fails. The return value stays 1 on success.

test_net: a fake whose reads return 8 bytes at a time; no reply was
terminated before, and a read error after the first read returned
success. httpget in PPSSPP (real HTTP, 20000-byte reply): unterminated
before; in full, cut to 99 characters, and empty after a 404 now.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T16:01:00.926986Z ca82b85 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dogo
dogo merged commit a92519a into master Nov 5, 2026
14 checks passed
@dogo
dogo deleted the fix/post-form-response branch November 6, 2026 23:00
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

Successfully merging this pull request may close these issues.

1 participant