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
Branches
Tags
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, ...@@ -2309,6 +2309,7 @@ static JSBool js_file_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
{ {
jsval idval; jsval idval;
int32 i=0; int32 i=0;
uint32 u=0;
jsint tiny; jsint tiny;
private_t* p; private_t* p;
jsrefcount rc; jsrefcount rc;
...@@ -2346,26 +2347,26 @@ static JSBool js_file_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict, ...@@ -2346,26 +2347,26 @@ static JSBool js_file_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
break; break;
case FILE_PROP_POSITION: case FILE_PROP_POSITION:
if(p->fp!=NULL) { if(p->fp!=NULL) {
if(!JS_ValueToInt32(cx,*vp,&i)) if(!JS_ValueToECMAUint32(cx, *vp, &u))
return(JS_FALSE); return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
fseek(p->fp,i,SEEK_SET); fseek(p->fp, u, SEEK_SET);
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
} }
break; break;
case FILE_PROP_DATE: case FILE_PROP_DATE:
if(!JS_ValueToInt32(cx,*vp,&i)) if(!JS_ValueToECMAUint32(cx, *vp, &u))
return(JS_FALSE); return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
setfdate(p->name,i); setfdate(p->name, u);
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
break; break;
case FILE_PROP_LENGTH: case FILE_PROP_LENGTH:
if(p->fp!=NULL) { if(p->fp!=NULL) {
if(!JS_ValueToInt32(cx,*vp,&i)) if(!JS_ValueToECMAUint32(cx, *vp, &u))
return(JS_FALSE); return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
chsize(fileno(p->fp),i); chsize(fileno(p->fp), u);
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
} }
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment