server: pass the escaped buffer, not escape_json()'s length, to %s - #48
Merged
Merged
Conversation
Since 1e92d52 escape_json() returns the number of bytes written, but the /api/rtsp and /api/onvif handlers still passed its return value straight to sprintf's %s, so any authenticated GET of those endpoints dereferenced a small integer and crashed divinus with SIGSEGV. Opening the web UI triggers it. Escape into the buffers first and pass the buffers. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Jamp
added a commit
to Jamp/chuangmi-ipc017-openipc
that referenced
this pull request
Sep 23, 2026
…vinus - autostart.sh sustituye sysupgrade y firstboot por un aviso: el botón "Firmware update" de la web de majestic los ejecuta y aquí no reconocen las particiones de fábrica. - La caída de la web de divinus queda aislada (/api/onvif y /api/rtsp) y arreglada en OpenIPC/divinus#48; se retira el borrador del issue. - Borrador de la discusión de hardware para OpenIPC/firmware. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
PR Summary by QodoPrevent RTSP and ONVIF API crashes during JSON formatting
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper |
Member
|
Thank you for your second commit, I truly appreciate those contributions and encourage you to submit anytime again in the future! Un saludo cordial, y ¡gracias de nuevo! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since
1e92d52("Sharing JSON escaping…"),escape_json()returns the number of byteswritten (
int), but the/api/rtspand/api/onvifhandlers still pass its returnvalue straight to
sprintf's%s. sprintf then dereferences that small integer as apointer, and any authenticated
GET /api/rtsporGET /api/onvifkills divinus withSIGSEGV (
Error occured (11)! Quitting...). The web UI requests/api/onvifwhen itloads, so simply opening it takes the stream down.
The fix escapes into the existing buffers first and passes the buffers (3 call sites).
Tested on a Xiaomi/Chuangmi ipc017 (SSC323 + GC2053, infinity6), divinus
1e92d52:GET /api/onvifcrashesit (2/2), and so does
GET /api/rtsp; unauthenticated requests get 401 and survive./api/onvif→{"enable":true,"enable_auth":true,"auth_user":"rtsp",…},/api/rtsp→{…"port":554,"auth_user":"rtsp","audio_codec":"mp3",…}; all other/api/*endpoints and/return 200; 5 rounds of 11 concurrent requests (the web UIload pattern), 55/55 × 200, same PID, no restart, encoder steady at 20 fps.
🤖 Generated with Claude Code