Skip to content
Draft
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
36 changes: 18 additions & 18 deletions modules/amt_heci.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,32 +262,32 @@ function amt_heci() {
fn.apply(this, opt);
}, callback, optional);
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 πŸ”΄ getProtocolVersion uses undefined 'opt' instead of 'optional' when building the optional args array

In getProtocolVersion, changed opt.push(arguments[i]) to optional.push(arguments[i]) in the argument-collection loop, matching the declared var optional = [] and mirroring the pattern used by every other method in the file.

πŸ€– Prompt for AI agents
In modules/amt_heci.js around line 264, review and complete this code-review fix: getProtocolVersion uses undefined 'opt' instead of 'optional' when building the optional args array.
What the draft fix changed: In getProtocolVersion, changed `opt.push(arguments[i])` to `optional.push(arguments[i])` in the argument-collection loop, matching the declared `var optional = []` and mirroring the pattern used by every other method in the file.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

this.startConfiguration = function () {
this.startConfiguration = function (callback) {
var optional = [];
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
this.sendCommand(0x29, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
this.sendCommand(0x29, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
}
this.stopConfiguration = function () {
this.stopConfiguration = function (callback) {
var optional = [];
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
this.sendCommand(0x5E, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
this.sendCommand(0x5E, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
}
this.openUserInitiatedConnection = function () {
this.openUserInitiatedConnection = function (callback) {
var optional = [];
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
this.sendCommand(0x44, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
this.sendCommand(0x44, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
}
this.closeUserInitiatedConnection = function () {
this.closeUserInitiatedConnection = function (callback) {
var optional = [];
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
this.sendCommand(0x45, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
this.sendCommand(0x45, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
}
this.getRemoteAccessConnectionStatus = function () {
this.getRemoteAccessConnectionStatus = function (callback) {
var optional = [];
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
this.sendCommand(0x46, data, function (header, fn, opt) {
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
this.sendCommand(0x46, null, function (header, fn, opt) {
if (header.Status == 0) {
var hostname = v.slice(14, header.Data.readUInt16LE(12) + 14).toString()
var hostname = header.Data.slice(14, header.Data.readUInt16LE(12) + 14).toString()
opt.unshift({ status: header.Status, networkStatus: header.Data.readUInt32LE(0), remoteAccessStatus: header.Data.readUInt32LE(4), remoteAccessTrigger: header.Data.readUInt32LE(8), mpsHostname: hostname, raw: header.Data });
} else {
opt.unshift({ status: header.Status });
Comment on lines 262 to 293

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 πŸ”΄ amt_heci.js sendCommand references undefined 'callback' variable via unshifted arguments, and multiple call sites reference undefined 'data'

Fixed startConfiguration, stopConfiguration, openUserInitiatedConnection, closeUserInitiatedConnection, and getRemoteAccessConnectionStatus: each now declares callback as its named parameter (function signature changed from function () to function (callback)), the optional-args loop starts at index 1 instead of 2 (consistent with callback now being argument 0), and the undefined data variable passed to sendCommand was replaced with null since none of these commands send a request payload in the original code. This resolves the ReferenceErrors on data and callback in all five methods.

(Automatically downgraded: no change in this fix lands near this finding's line β€” verify whether it was actually addressed.)

πŸ€– Prompt for AI agents
In modules/amt_heci.js around line 233, review and complete this code-review fix: amt_heci.js sendCommand references undefined 'callback' variable via unshifted arguments, and multiple call sites reference undefined 'data'.
What the draft fix changed: Fixed startConfiguration, stopConfiguration, openUserInitiatedConnection, closeUserInitiatedConnection, and getRemoteAccessConnectionStatus: each now declares `callback` as its named parameter (function signature changed from `function ()` to `function (callback)`), the optional-args loop starts at index 1 instead of 2 (consistent with callback now being argument 0), and the undefined `data` variable passed to `sendCommand` was replaced with `null` since none of these commands send a request payload in the original code. This resolves the ReferenceErrors on `data` and `callback` in all five methods.

_(Automatically downgraded: no change in this fix lands near this finding's line β€” verify whether it was actually addressed.)_
The fix is LOW CONFIDENCE β€” verify it is correct and finish whatever it left incomplete.

fix confidence: πŸ”΄ 40 low β€” review closely β€” react πŸ‘/πŸ‘Ž to teach the reviewer

Comment on lines 262 to 293

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 πŸ”΄ getRemoteAccessConnectionStatus references undefined variable 'v' when parsing hostname

In getRemoteAccessConnectionStatus's sendCommand callback, replaced the undefined v.slice(...) with header.Data.slice(...), since header.Data is the buffer actually available in that closure (there is no analog to getVersion's local v here) and the surrounding code already reads offsets 0/4/8/12 from header.Data, making it the correct source buffer for the hostname bytes at offset 14.

πŸ€– Prompt for AI agents
In modules/amt_heci.js around line 251, review and complete this code-review fix: getRemoteAccessConnectionStatus references undefined variable 'v' when parsing hostname.
What the draft fix changed: In getRemoteAccessConnectionStatus's sendCommand callback, replaced the undefined `v.slice(...)` with `header.Data.slice(...)`, since `header.Data` is the buffer actually available in that closure (there is no analog to getVersion's local `v` here) and the surrounding code already reads offsets 0/4/8/12 from `header.Data`, making it the correct source buffer for the hostname bytes at offset 14.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 85 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

Expand All @@ -297,7 +297,7 @@ function amt_heci() {
}
this.getProtocolVersion = function (callback) {
var optional = [];
for (var i = 1; i < arguments.length; ++i) { opt.push(arguments[i]); }
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }

heci.doIoctl(heci.IOCTL.HECI_VERSION, Buffer.alloc(5), Buffer.alloc(5), function (status, buffer, self, fn, opt) {
if (status == 0) {
Expand All @@ -313,4 +313,4 @@ function amt_heci() {
}
}

module.exports = amt_heci;
module.exports = amt_heci;