Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Synergy — collaboration notes

## Working style

- **Never configure or build unless explicitly asked.** No `cmake`, `cmake --build`, `make`, `ninja`, etc. After code changes, stop at the edit and ask the user to build manually.

## GitHub Actions

- `matrix` context is NOT available in job-level `if` — the `if` runs before the matrix is expanded. Use step-level `if` conditions instead (e.g. set a `skip` output in a setup step and check it per-step).

## Code style

- Default to **no comments**. Only add one when the WHY is non-obvious — hidden constraints, subtle invariants, workarounds for specific bugs, behavior that would surprise a reader. Never add comments that explain WHAT or HOW (well-named identifiers do that).
Expand Down
18 changes: 18 additions & 0 deletions src/lib/deskflow/IClipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include "deskflow/IClipboard.h"
#include "base/Log.h"
#include "common/stdvector.h"

//
Expand All @@ -28,17 +29,28 @@
assert(clipboard != NULL);

const char *index = data.data();
const char *const end = index + data.size();

if (clipboard->open(time)) {
// clear existing data
clipboard->empty();

// read the number of formats
const UInt32 numFormats = readUInt32(index);
if (end - index < 4) {
LOG_ERR("clipboard unmarshall: truncated header");
clipboard->close();
return;
}
index += 4;

// read each format
for (UInt32 i = 0; i < numFormats; ++i) {

Check warning on line 48 in src/lib/deskflow/IClipboard.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Reduce the number of nested "break" statements from 2 to 1 authorized.

See more on https://sonarcloud.io/project/issues?id=symless_synergy&issues=AZ3T2N6NHvYeq16tVXJB&open=AZ3T2N6NHvYeq16tVXJB&pullRequest=176
// need 8 bytes for format id + payload size
if (end - index < 8) {
LOG_ERR("clipboard unmarshall: truncated format header at %u/%u", i, numFormats);
break;
}
// get the format id
IClipboard::EFormat format = static_cast<IClipboard::EFormat>(readUInt32(index));
index += 4;
Expand All @@ -47,6 +59,12 @@
UInt32 size = readUInt32(index);
index += 4;

// peer-supplied size must not exceed remaining buffer
if (size > static_cast<UInt32>(end - index)) {
LOG_ERR("clipboard unmarshall: payload size %u exceeds remaining %zd", size, end - index);
break;
}

// save the data if it's a known format. if either the client
// or server supports more clipboard formats than the other
// then one of them will get a format >= kNumFormats here.
Expand Down
Loading