File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,13 @@ impl FileDesc {
7676 -> io:: Result < isize >
7777 {
7878 use libc:: pread64;
79- cvt ( pread64 ( fd, buf, count, offset as i32 ) )
79+ // pread64 on emscripten actually takes a 32 bit offset
80+ if let Ok ( o) = offset. try_into ( ) {
81+ cvt ( pread64 ( fd, buf, count, o) )
82+ } else {
83+ Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
84+ "cannot pread >2GB" ) )
85+ }
8086 }
8187
8288 #[ cfg( not( any( target_os = "android" , target_os = "emscripten" ) ) ) ]
@@ -117,7 +123,13 @@ impl FileDesc {
117123 -> io:: Result < isize >
118124 {
119125 use libc:: pwrite64;
120- cvt ( pwrite64 ( fd, buf, count, offset as i32 ) )
126+ // pwrite64 on emscripten actually takes a 32 bit offset
127+ if let Ok ( o) = offset. try_into ( ) {
128+ cvt ( pwrite64 ( fd, buf, count, o) )
129+ } else {
130+ Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
131+ "cannot pwrite >2GB" ) )
132+ }
121133 }
122134
123135 #[ cfg( not( any( target_os = "android" , target_os = "emscripten" ) ) ) ]
You can’t perform that action at this time.
0 commit comments