Commit Graph
27 Commits
Author SHA1 Message Date
Jash 1e7d8e1dd9 fix: cast tv_usec for %jd so armhf varargs stay aligned refs #4580 2026-08-26 11:23:11 +05:30
Jash bd3097be58 fix: escape JSON strings in a single pass so quotes are not double-escaped 2026-08-17 04:39:24 +05:30
Jash 3983db5357 fix: percent-encode non-ASCII bytes in UriEncode and escape go2rtc JSON fields 2026-08-16 15:37:21 +05:30
Isaac Connor 706d9324f2 feat: allow newlines to separate entries in the monitor Options field
The Options field was a single line text input, so a list of options had to
be typed as one comma separated run. Make it a textarea, sized to the number
of entries it already holds, so each option can go on its own line.

Nothing needs to parse this: both consumers already take a set of separator
characters, they were just never given the newlines.
av_dict_parse_string() (Ffmpeg) and Split() (Libvlc) both skip empty
entries, so a blank line, crlf, or a trailing newline all work, and comma
separated values keep working unchanged.

The separator set is a named constant rather than a literal at each call
site so the tests exercise the value the cameras actually pass - with a
literal they would keep passing if a call site were reverted. Verified by
setting it back to "," which fails both test cases.
2026-08-08 11:56:43 -04:00
Isaac ConnorandClaude Opus 4.8 813bf6f1a3 fix: bound HTTP camera response header copies to prevent buffer overflow
RemoteCameraHTTP::GetResponse()'s non-PCRE parser (the default when built
without PCRE) copied server-controlled HTTP response header values into
fixed-size static buffers with unbounded strcpy()/sprintf(), and with
strncpy() bounds derived from delimiters rather than the buffer size. A
malicious or MitM'd HTTP camera could overflow status_mesg[256],
connection_type[32], content_type[32] and content_boundary[64],
corrupting adjacent parser state (content_length, content_boundary_len)
for DoS and secondary heap corruption.

Add zm_strncpy(): a bounded copy that always null-terminates (strcpy
overflows; strncpy skips the terminator on truncation) and optionally
caps to a field length n for delimiter-bounded values whose source is
not null-terminated at the field end. Route every header copy in
GetResponse() through it. The content_boundary "--" prefix is written
separately and content_boundary_len is taken from strlen() of the
resulting (now bounded) string so the compare length at the multipart
subheader match stays correct.

The two subcontent-header strncpy() calls were already bounded to
sizeof-1 with an explicit terminator and are left as-is.

Adds a tests/zm_utils.cpp self-check covering fit, truncation,
delimiter-limit, delimiter-over-buffer, and empty-source cases.

Refs GHSA-93j4-rcp9-9jx6.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-26 20:30:42 -04:00
Isaac Connor 334994bd3f Fix appending %% instead of % when uri decoding. Add test for URIEncode 2026-02-04 20:45:46 -05:00
Isaac Connor 365830a9ae Rough in remove_password function + tests 2022-07-04 09:53:50 -04:00
Isaac Connor c3d7c306fc Add tests for mask_authentication 2022-04-18 13:33:22 -04:00
Peter Keresztes Schmidt 46155942c1 Misc: Rename namespace ZM to zm
We had a mixture of both spellings. Unify it according to our code-style.
2021-06-06 19:11:11 +02:00
Peter Keresztes Schmidt d2932b5d68 Utils: Add a ByteArrayToHexString helper 2021-05-30 22:53:05 +02:00
Peter Keresztes Schmidt c2a7f7b593 tests/Box: Add unit tests 2021-05-16 16:42:58 +02:00
Peter Keresztes Schmidt 07e49e47af utils: Add a clamping function mimicking std::clamp
This can be replaced with std::clamp in C++17.
2021-04-25 23:13:21 +02:00
Peter Keresztes Schmidt 545f0dbb96 utils: cleanup Base64Encode 2021-04-04 00:39:40 +02:00
Peter Keresztes Schmidt e330f8553d utils: cleanup Split and Join 2021-04-04 00:30:18 +02:00
Peter Keresztes Schmidt 39a896f5b6 utils: cleanup StartsWith 2021-04-03 23:51:12 +02:00
Peter Keresztes Schmidt 3dbf13e00b utils: cleanup ReplaceAll 2021-04-03 23:50:35 +02:00
Peter Keresztes Schmidt 664cd649f8 utils: cleanup Trim (was trimSet) and TrimSpaces 2021-04-03 23:30:59 +02:00
Peter Keresztes Schmidt 3968a411a0 tests/utils: Add tests for QueryString 2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt fa7c420442 tests/utils: Add tests for UriDecode 2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt 46a4b615c8 tests/utils: Add tests for base64Encode
Test vectors according to RFC4648
2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt bbc4afcf1b tests/utils: Add tests for join 2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt e54c10fdb4 tests/utils: Add tests for StringVector split(const std::string&, const std::string&, int limit=0) 2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt 64cf69ebc1 tests/utils: Add tests for int split(const char*, const char, std::vector<std::string>&) 2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt bde0bde066 tests/utils: Add tests for startsWith 2021-04-03 22:35:03 +02:00
Peter Keresztes Schmidt 13f91b5826 tests/utils: Add tests for replaceAll 2021-04-03 22:35:03 +02:00
Peter Keresztes Schmidt 6150ceeb17 tests/utils: Add tests for trimSpaces 2021-04-03 22:35:03 +02:00
Peter Keresztes Schmidt 4529e59b1d tests/utils: Add tests for trimSet 2021-04-03 22:35:03 +02:00