Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
c920d0da
Commit
c920d0da
authored
Mar 02, 2022
by
Rob Swindell
💬
Browse files
Fix possible negative offset to lseek()
CID 327965
parent
4f11e1df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
src/sbbs3/js_file.c
src/sbbs3/js_file.c
+12
-9
No files found.
src/sbbs3/js_file.c
View file @
c920d0da
...
...
@@ -406,15 +406,18 @@ js_raw_read(JSContext *cx, uintN argc, jsval *arglist)
* required by POSIX.
*/
fflush
(
p
->
fp
);
pos
=
ftell
(
p
->
fp
);
fd
=
fileno
(
p
->
fp
);
lseek
(
fd
,
pos
,
SEEK_SET
);
len
=
read
(
fileno
(
p
->
fp
),
buf
,
len
);
fseeko
(
p
->
fp
,
pos
+
(
len
>=
0
?
len
:
0
),
SEEK_SET
);
dbprintf
(
FALSE
,
p
,
"read %u raw bytes"
,
len
);
if
(
len
<
0
)
len
=
0
;
pos
=
ftello
(
p
->
fp
);
if
(
pos
<
0
)
len
=
0
;
else
{
fd
=
fileno
(
p
->
fp
);
lseek
(
fd
,
pos
,
SEEK_SET
);
len
=
read
(
fileno
(
p
->
fp
),
buf
,
len
);
fseeko
(
p
->
fp
,
pos
+
(
len
>=
0
?
len
:
0
),
SEEK_SET
);
dbprintf
(
FALSE
,
p
,
"read %d raw bytes"
,
len
);
if
(
len
<
0
)
len
=
0
;
}
JS_RESUMEREQUEST
(
cx
,
rc
);
str
=
JS_NewStringCopyN
(
cx
,
buf
,
len
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment