In KEYFRAMESONDEMAND mode without viewers, only keyframes are decoded.
Non-keyframe packets skip decoding and never reach the Phase 5 code
that updates last_write_time. If the keyframe interval exceeds
ZM_WATCH_MAX_DELAY, zmwatch sees the stale timestamp and restarts
the capture daemon unnecessarily.
Update last_write_time for skipped video packets so zmwatch knows the
decode thread is still processing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The monitor form has password fields for camera credentials (ONVIF,
RTSP) which triggered Chrome's "save password" prompt on every save
or navigation.
Convert "Save and Close" from native form submit to AJAX via
saveMonitorData() with redirect, matching how "Save" already works.
Clear password field values before any remaining native form
submissions (Type/Method changes) and on pagehide, since the values
are repopulated from the database on reload. Remove the ineffective
dummy hidden password field.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When using DECODING_ONDEMAND or DECODING_KEYFRAMESONDEMAND, packets
accumulate in the decoder_queue while a viewer is connected. When the
viewer disconnects, should_decode becomes false but stale packets
remain queued in the decoder indefinitely — Phase 1 tries
receive_frame (gets EAGAIN), Phase 2 skips sending new packets, and
the cycle repeats.
Flush the decoder via avcodec_flush_buffers in both Phase 1 (before
attempting receive_frame) and Phase 2 (after determining decoding is
not needed), marking queued packets as decoded and clearing the queue.
This releases held packet locks and resets the decoder so it starts
clean when a viewer reconnects.
Also rename the 'dominated' variable to 'already_decoded' for clarity.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Check container.length instead of just container (empty jQuery objects are truthy)
- Guard against container[0] being undefined before accessing lastElementChild
- Add check for bottomEl.length before calling offset() on it
Fixes TypeError when scaleToFit is called with a selector that matches nothing.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When auth_hash changes, auth_relay must also be updated to stay in sync.
The event.js getCmdResponse was only updating auth_hash, which could
cause requests to use stale auth_relay values.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The PHP status.php returns 'auth' but getStatusCmdResponse was checking
for 'auth_hash'. This mismatch prevented auth hash updates from status
responses from ever being applied, causing invalid hash errors after
the auth expired.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix SQL injection vulnerability in migrateHash() by using prepared statements
- Add null/empty check in password_type() to prevent array access error
- Remove dead code branch in generateAuthHash() (unreachable $_SESSION check)
- Fix PHP version in error message (5.3 -> 5.5 for password_hash)
- Prevent username enumeration by using consistent error messages
- Fix spacing inconsistency in substr() call
- Add TODO comment about MD5 hash weakness
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added started flag checks in streamCommand() and streamCmdQuery() to
prevent commands from being sent after the stream has been killed.
This fixes an issue where scale commands were being sent after quit
commands during page reload.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change var to let/const for proper block scoping
- Use const for variables that are not reassigned
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change var to let/const for proper block scoping in for loops and
conditionals
- Fix variable shadowing (renamed inner 'el' to 'element')
- Remove erroneous semicolons after function declaration and else block
- Use const for variables that are not reassigned
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix typo 'btn-primaryary' -> 'btn-primary' which prevented the
class from being removed when toggling analyse mode
- Declare CheckMethod and el variables with let to avoid creating
implicit globals
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace var with let in for loop declarations for proper block scoping.
Affects console.js, monitor.js, montage.js, montagereview.js, zone.js,
and zones.js.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change click_AutoEmail, click_automove, click_autocopy to use the
'element' parameter instead of 'this' for consistency
- Remove debug console.log statements for availableTags, operator
defaults, and term parsing
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move the escapeHTML function from filter.js to skin.js so it can be
reused across views. Also switch from textarea-based encoding to
explicit string replacement which is cleaner and doesn't require
maintaining a DOM element.
This also fixes the issue where 'escape' variable shadowed the
built-in JavaScript escape function.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The bracket select options were missing the closing > in their
opening tags, causing invalid HTML to be generated.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The WS-Security timestamp had only a 10-second validity window, which
caused intermittent "not authorized" errors when there was clock drift
between ZoneMinder and the camera.
Changes:
- Increase default timestamp validity from 10 to 60 seconds
- Add configurable timestamp_validity option (range 10-600 seconds)
- Add better error diagnostics for auth failures showing timestamp_validity
and camera_clock_offset values
- Update parse_onvif_options documentation
Users experiencing auth errors due to clock drift can now set
onvif_options=timestamp_validity=120 (or higher) as a workaround.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The nvidia-vaapi-driver would fail with "list argument exceeds maximum
number" when decoding HEVC because GPU surfaces were being held in the
packet queue after transfer, exhausting the VAAPI surface pool.
Changes:
- Transfer hw frames to software immediately in receive_frame() while
the VA context is still valid, then release the GPU surface
- Check hw_frames_ctx in needs_hw_transfer() to detect already-transferred
frames
- Remove extra_hw_frames and thread_count settings (not needed with
immediate surface release)
- Fix EAGAIN handling in send_packet to wait instead of busy-loop
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Buffer was sized for binary in6_addr (16 bytes) but inet_ntop needs
space for string representation (INET6_ADDRSTRLEN = 46 bytes).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Apply credentials to secondary stream URL in FFmpegCamera (was causing 401 Unauthorized)
- Add empty check for rtsp_second_path in RTSP2WebManager before applying credentials
- Replace unsafe sprintf pattern in Monitor::DumpSettings with std::string + stringtf
- Refactor Zone::DumpSettings to return std::string instead of writing to char buffer
- Add decimal precision to event duration debug output
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The second byte extraction was duplicating the first byte instead
of extracting the second byte with (in_pf>>8)&0xff.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change lock_fd error check from <= 0 to < 0 since open() returns -1
on error and 0 is a valid file descriptor
- Use -1 consistently as invalid fd marker
- Fix close check from > 0 to >= 0 to handle fd 0 correctly
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add input validation and shell argument escaping to prevent OS command
injection via the 'show' parameter in web/views/image.php. The parameter
is now validated against an allowlist and all values passed to exec()
are wrapped with escapeshellarg().
Also fix PHP operator precedence bug in shutdown.php where 'and' was
used instead of '&&', causing the 'when' parameter validation to not
work as intended.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add null check for avformat_alloc_context() return value
- Add null checks for avformat_new_stream() and avcodec_alloc_context3()
- Fix copy-paste bug using smStaticPayloads instead of smDynamicPayloads
when setting codec_name for dynamic payloads
- Fix memory leak by freeing codec_context after copying parameters
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>