Skip to content

validate trigger registration lengths - #6184

Open
WalidNejmi wants to merge 1 commit into
bloomberg:mainfrom
WalidNejmi:trigger-register-length-gh
Open

validate trigger registration lengths#6184
WalidNejmi wants to merge 1 commit into
bloomberg:mainfrom
WalidNejmi:trigger-register-length-gh

Conversation

@WalidNejmi

Copy link
Copy Markdown

Validate the raw NET_TRIGGER_REGISTER / NET_TRIGGER_UNREGISTER payload against the actual received length before parsing. Also replace the unbounded strcpy() into info->spname with a bounded memcpy() plus explicit NUL terminator.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens trigger registration/unregistration message handling by validating NET_TRIGGER_REGISTER / NET_TRIGGER_UNREGISTER payload lengths before parsing and by removing an unbounded strcpy() into the stored procedure name buffer.

Changes:

  • Add valid_trigger_reg_payload() to validate incoming trigger register/unregister packets against dtalen before invoking trigger logic.
  • Replace strcpy(info->spname, ...) with bounded memcpy(..., spname_len) plus explicit NUL termination.
  • Add early rejection/logging for malformed trigger registration/unregistration packets.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
db/trigger.c Replaces unbounded string copy when storing trigger SP name.
db/glue.c Adds payload-length validation for trigger register/unregister network handlers.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread db/glue.c
Comment on lines +3545 to +3550
if (!valid_trigger_reg_payload(dtap, dtalen)) {
logmsg(LOGMSG_ERROR,
"%s: invalid trigger registration payload length %d\n",
__func__, dtalen);
return;
}
Comment thread db/glue.c
Comment on lines +3562 to +3567
if (!valid_trigger_reg_payload(dtap, dtalen)) {
logmsg(LOGMSG_ERROR,
"%s: invalid trigger unregister payload length %d\n",
__func__, dtalen);
return;
}
Comment thread db/trigger.c
Comment on lines +121 to +125
add: info = malloc(sizeof(trigger_info_t) + (size_t)t->spname_len + 1);
info->host = intern(trigger_hostname(t));
info->trigger_cookie = t->trigger_cookie;
info->hbeat = now;
strcpy(info->spname, t->spname);
memcpy(info->spname, t->spname, (size_t)t->spname_len);
Comment thread db/glue.c
Comment on lines +3532 to +3535
const char *hostname = spname + spname_len + 1;

if (memchr(hostname, '\0', remaining) == NULL)
return 0;
@WalidNejmi
WalidNejmi force-pushed the trigger-register-length-gh branch from 2805860 to 063d19c Compare September 1, 2026 14:01

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
logfill [db unavailable at finish] **quarantined**
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

@WalidNejmi

Copy link
Copy Markdown
Author

/plugin-branch trigger-length

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
sc_redo [failed with core dumped]
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**
sc_truncate_lockorder_generated [timeout] **quarantined**
reco-ddlk-sql [timeout] **quarantined**

@WalidNejmi

Copy link
Copy Markdown
Author

/plugin-branch trigger-register-length

@WalidNejmi

Copy link
Copy Markdown
Author

/adhoc-test tsa

@WalidNejmi

Copy link
Copy Markdown
Author

/plugin-branch trigger-register-length

@WalidNejmi

Copy link
Copy Markdown
Author

/runtests

Validate the raw NET_TRIGGER_REGISTER / NET_TRIGGER_UNREGISTER payload
against the actual received length before parsing, using
offsetof(trigger_reg_t, spname) as the variable-data boundary and reading
spname_len into a temporary (no double byteswap, no packet mutation).
Also replace the unbounded strcpy() into info->spname with a bounded
memcpy() plus explicit NUL terminator.
@WalidNejmi
WalidNejmi force-pushed the trigger-register-length-gh branch from 063d19c to 7f99f29 Compare September 4, 2026 16:55
@WalidNejmi

Copy link
Copy Markdown
Author

/plugin-branch trigger-register-length

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cbuild submission: Error ⚠.
Regression testing: Success ✓.

The first 10 failing tests are:
sc_redo [failed with core dumped]
comdb2sys **quarantined**
ssl_san
consumer_non_atomic_default_consumer_generated **quarantined**
ssl_set_cmd
ssl_dbname
ssl_prefer
sc_downgrade [timeout] **quarantined**
reco-ddlk-sql [timeout] **quarantined**
sql_logfill_autodisable [timeout]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants