Skip to content

Commit 15a7662

Browse files
committed
Address comments
1 parent ad8fab4 commit 15a7662

4 files changed

Lines changed: 17 additions & 4 deletions

File tree

demo/electron/car/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ in real time.
2222

2323
```bash
2424
cd demo/electron/car
25+
source /opt/ros/<distro>/setup.bash # required before install and launch
2526
npm install
26-
source /opt/ros/<distro>/setup.bash # required before launch
2727
npm start
2828
```
2929

demo/electron/manipulator/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Three.js. It publishes and subscribes to `sensor_msgs/msg/JointState` on
2323

2424
```bash
2525
cd demo/electron/manipulator
26+
source /opt/ros/<distro>/setup.bash # required before install and launch
2627
npm install
27-
source /opt/ros/$ROS_DISTRO/setup.bash # required before launch
2828
npm start
2929
```
3030

demo/electron/turtle_tf2/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ turtlesim, and makes turtle2 follow turtle1.
2626

2727
```bash
2828
cd demo/electron/turtle_tf2
29+
source /opt/ros/<distro>/setup.bash # required, in the same terminal as npm install / npm start
2930
npm install
30-
source /opt/ros/$ROS_DISTRO/setup.bash # required, in the same terminal as npm start
3131
ros2 run turtlesim turtlesim_node # in another sourced terminal
3232
npm start
3333
```

lib/native_loader.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,15 @@ function mirrorPrebuiltToBuildRelease(srcPath) {
4646
return;
4747
}
4848
fs.mkdirSync(destDir, { recursive: true });
49-
fs.copyFileSync(srcPath, destPath);
49+
// COPYFILE_EXCL guarantees we never overwrite an existing build output,
50+
// even if another process created it after the existsSync check above.
51+
fs.copyFileSync(srcPath, destPath, fs.constants.COPYFILE_EXCL);
5052
debug(`Mirrored prebuilt binary to ${destPath}`);
5153
} catch (e) {
54+
if (e.code === 'EEXIST') {
55+
// Another process mirrored the binary first; leave it untouched.
56+
return;
57+
}
5258
debug('Could not mirror prebuilt binary to build/Release:', e.message);
5359
}
5460
}
@@ -120,6 +126,13 @@ function customFallbackLoader() {
120126
arch,
121127
runtime,
122128
});
129+
// The filename is built from environment-derived values (notably
130+
// ROS_DISTRO); ensure it stays a plain basename so it cannot escape
131+
// prebuildDir via path separators before we join/require/copy it.
132+
if (path.basename(candidate) !== candidate) {
133+
debug(`Rejecting suspicious prebuilt filename: ${candidate}`);
134+
return null;
135+
}
123136
const candidatePath = path.join(prebuildDir, candidate);
124137

125138
if (fs.existsSync(candidatePath)) {

0 commit comments

Comments
 (0)