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

Use JS_ValueToECMAUint32 for File position, date, and length properties

This resolves errors when setting these properties to values > 2147483647
example:
!JavaScript  /sbbs/exec/load/sauce_lib.js line 69: Error: can't convert
2430770157 to an integer

That means you can now seek around (set position) within files > 2GB, truncate
or extend a file > 2GB, or set a file's date to > Jan-19-2038.
parent b35365c2
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #1982 passed
......@@ -2309,6 +2309,7 @@ static JSBool js_file_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
{
jsval idval;
int32 i=0;
uint32 u=0;
jsint tiny;
private_t* p;
jsrefcount rc;
......@@ -2346,26 +2347,26 @@ static JSBool js_file_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
break;
case FILE_PROP_POSITION:
if(p->fp!=NULL) {
if(!JS_ValueToInt32(cx,*vp,&i))
if(!JS_ValueToECMAUint32(cx, *vp, &u))
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
fseek(p->fp,i,SEEK_SET);
fseek(p->fp, u, SEEK_SET);
JS_RESUMEREQUEST(cx, rc);
}
break;
case FILE_PROP_DATE:
if(!JS_ValueToInt32(cx,*vp,&i))
if(!JS_ValueToECMAUint32(cx, *vp, &u))
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
setfdate(p->name,i);
setfdate(p->name, u);
JS_RESUMEREQUEST(cx, rc);
break;
case FILE_PROP_LENGTH:
if(p->fp!=NULL) {
if(!JS_ValueToInt32(cx,*vp,&i))
if(!JS_ValueToECMAUint32(cx, *vp, &u))
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
chsize(fileno(p->fp),i);
chsize(fileno(p->fp), u);
JS_RESUMEREQUEST(cx, rc);
}
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment