@soleur/opencode 3.378.8 → 3.378.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -39,9 +39,13 @@
|
|
|
39
39
|
|
|
40
40
|
import {
|
|
41
41
|
chmodSync,
|
|
42
|
+
closeSync,
|
|
43
|
+
constants,
|
|
42
44
|
copyFileSync,
|
|
43
45
|
existsSync,
|
|
46
|
+
fstatSync,
|
|
44
47
|
mkdirSync,
|
|
48
|
+
openSync,
|
|
45
49
|
readFileSync,
|
|
46
50
|
readdirSync,
|
|
47
51
|
renameSync,
|
|
@@ -140,8 +144,23 @@ export function walkPayloadFiles(root: string, dir: string): Array<[string, Payl
|
|
|
140
144
|
}
|
|
141
145
|
if (!entry.isFile()) continue;
|
|
142
146
|
const full = join(root, path);
|
|
143
|
-
|
|
144
|
-
|
|
147
|
+
// One descriptor for kind + mode + bytes: a stat-then-read window would let
|
|
148
|
+
// a mid-walk swap change what is observed between the two calls (CodeQL
|
|
149
|
+
// js/file-system-race). O_NOFOLLOW turns a symlink swapped in after the
|
|
150
|
+
// Dirent check into an ELOOP error rather than a dereference — the refusal
|
|
151
|
+
// above only saw the entry as it was at readdir time — and O_NONBLOCK keeps
|
|
152
|
+
// a swapped-in FIFO from parking the install. Kind is re-checked on the
|
|
153
|
+
// descriptor, not trusted from the Dirent.
|
|
154
|
+
const fd = openSync(full, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
155
|
+
try {
|
|
156
|
+
const st = fstatSync(fd);
|
|
157
|
+
if (!st.isFile()) {
|
|
158
|
+
throw new Error(`Refusing non-regular file in payload tree: ${full}`);
|
|
159
|
+
}
|
|
160
|
+
found.push([path, { content: readFileSync(fd, "utf-8"), executable: (st.mode & 0o111) !== 0 }]);
|
|
161
|
+
} finally {
|
|
162
|
+
closeSync(fd);
|
|
163
|
+
}
|
|
145
164
|
}
|
|
146
165
|
};
|
|
147
166
|
visit(dir);
|