Commit Graph
17 Commits
Author SHA1 Message Date
Isaac ConnorandClaude Opus 5.5 57e1a1b194 fix: bound the HTTP camera Content-Length and Buffer growth refs GHSA-x959-xrc9-89p8
RemoteCameraHttp read the camera's Content-Length with atoi() and then asked
ReadData() for that many bytes, which passes the count straight to
Buffer::read_into(). Buffer::expand() worked in int: once the allocation passed
INT_MAX the spare space went negative, it grew again, and mAllocation + count
wrapped to a small value, so the following memcpy or read() wrote the camera's
data past a small heap block. Whoever answers the camera's HTTP request, often
on a plain-HTTP link, could crash zmc in a loop or corrupt its heap.

- RemoteCameraHttp::ParseContentLength() replaces the four atoi() calls. It
  refuses a length that is not a number or is larger than twice the monitor's
  raw frame size plus one network buffer (capped at 1 GiB), and GetResponse()
  fails the response instead of buffering it.
- Buffer::expand() does its arithmetic in size_t, grows to exactly what is
  needed, and refuses to hold more than INT_MAX bytes, since read_into()
  returns the count as an int.
- Buffer::read_into() refuses a read that does not fit after expand() rather
  than reading past the allocation.

tests/zm_buffer.cpp covers reads through a pipe, an oversized read, data kept
across a shift and a grow, and the Content-Length bounds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 18:27:39 -04:00
Aaron Kling c4683d90a9 Format code using astyle google format
Commands used:
astyle --style=google --indent=spaces=2 --keep-one-line-blocks src/*.cpp
astyle --style=google --indent=spaces=2 --keep-one-line-blocks src/*.h
2024-03-26 13:43:58 -05:00
Alejandro Criado-Pérez 543683aa4c Corrections on cpp and h files 2023-08-13 01:27:19 +02:00
Isaac Connor 1b107b2e02 Must memset the new allocation or we can use an unitialized value from the buffer 2022-06-08 16:45:13 -04:00
Isaac Connor 5a57122891 fix typpo 2021-12-10 16:17:54 -05:00
Peter Keresztes Schmidt c823b9c00e Buffer: Convert API to std::chrono 2021-06-13 23:22:51 +02:00
Isaac Connor a0d08b8277 More debug in read_into 2021-04-17 12:50:26 -04:00
Isaac Connor 292bad8718 We can use >= instead of > to avoid an unneeded reallocation. Reduce duplicated code. 2021-03-25 12:52:41 -04:00
Isaac Connor 0af68a0914 Implement read_into with a timeout 2021-03-05 14:12:44 -05:00
Peter Keresztes Schmidt d9568a98c0 Drop zm_thread which has been replaced by STL implementations 2021-03-04 10:55:46 +01:00
Peter Keresztes Schmidt 0dbc39ee25 Cleanup and reorganize includes
With this commit a unified structure for includes is introduced.
The general rules:
 * Only include what you need
 * Include wherever possible in the cpp and forward-declare in the header

 The includes are sorted in a local to global fashion. This means for the include order:
  0. If cpp file: The corresponding h file and an empty line
  1. Includes from the project sorted alphabetically
  2. System/library includes sorted alphabetically
  3. Conditional includes
2021-02-04 18:02:01 +01:00
Isaac Connor 1b472edc2b fix cast 2020-11-21 16:58:22 -05:00
Isaac Connor 2cdf0da3c0 Remove unused includes and apply google code style 2020-11-21 09:15:36 -05:00
Andy Bauer 254fcbcef7 update gpl 2 mailing address in source files 2016-12-26 09:23:16 -06:00
Isaac Connor 03b1ced568 tabs to spaces and use 2space indenting 2016-04-04 10:11:48 -04:00
Isaac Connor 994de4ae0a Introduce a read_into function in the Buffer. Use it when reading over http from a camera to remove an extra mem copy. Limit reads to 1 network buffer instead of reading everything that is available. 2015-07-06 15:57:06 -04:00
nextime 33cbd89212 Migrate svn to git 2013-03-17 00:45:21 +01:00