Skip to content
Snippets Groups Projects
Commit c920d0da authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Fix possible negative offset to lseek()

CID 327965
parent 4f11e1df
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -406,15 +406,18 @@ js_raw_read(JSContext *cx, uintN argc, jsval *arglist) ...@@ -406,15 +406,18 @@ js_raw_read(JSContext *cx, uintN argc, jsval *arglist)
* required by POSIX. * required by POSIX.
*/ */
fflush(p->fp); fflush(p->fp);
pos = ftell(p->fp); pos = ftello(p->fp);
fd = fileno(p->fp); if(pos < 0)
lseek(fd, pos, SEEK_SET); len = 0;
len = read(fileno(p->fp),buf,len); else {
fseeko(p->fp, pos + (len >= 0 ? len : 0), SEEK_SET); fd = fileno(p->fp);
dbprintf(FALSE, p, "read %u raw bytes",len); lseek(fd, pos, SEEK_SET);
if(len<0) len = read(fileno(p->fp),buf,len);
len=0; 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); JS_RESUMEREQUEST(cx, rc);
str = JS_NewStringCopyN(cx, buf, len); str = JS_NewStringCopyN(cx, buf, len);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment