@@ -395,14 +395,14 @@ function readFileSync(path, options) {
395395}
396396
397397function close ( fd , callback ) {
398- validateUint32 ( fd , 'fd' ) ;
398+ validateInt32 ( fd , 'fd' , 0 ) ;
399399 const req = new FSReqCallback ( ) ;
400400 req . oncomplete = makeCallback ( callback ) ;
401401 binding . close ( fd , req ) ;
402402}
403403
404404function closeSync ( fd ) {
405- validateUint32 ( fd , 'fd' ) ;
405+ validateInt32 ( fd , 'fd' , 0 ) ;
406406
407407 const ctx = { } ;
408408 binding . close ( fd , undefined , ctx ) ;
@@ -449,7 +449,7 @@ function openSync(path, flags, mode) {
449449}
450450
451451function read ( fd , buffer , offset , length , position , callback ) {
452- validateUint32 ( fd , 'fd' ) ;
452+ validateInt32 ( fd , 'fd' , 0 ) ;
453453 validateBuffer ( buffer ) ;
454454 callback = maybeCallback ( callback ) ;
455455
@@ -487,7 +487,7 @@ Object.defineProperty(read, internalUtil.customPromisifyArgs,
487487 { value : [ 'bytesRead' , 'buffer' ] , enumerable : false } ) ;
488488
489489function readSync ( fd , buffer , offset , length , position ) {
490- validateUint32 ( fd , 'fd' ) ;
490+ validateInt32 ( fd , 'fd' , 0 ) ;
491491 validateBuffer ( buffer ) ;
492492
493493 offset |= 0 ;
@@ -524,7 +524,7 @@ function write(fd, buffer, offset, length, position, callback) {
524524 callback ( err , written || 0 , buffer ) ;
525525 }
526526
527- validateUint32 ( fd , 'fd' ) ;
527+ validateInt32 ( fd , 'fd' , 0 ) ;
528528
529529 const req = new FSReqCallback ( ) ;
530530 req . oncomplete = wrapper ;
@@ -564,7 +564,7 @@ Object.defineProperty(write, internalUtil.customPromisifyArgs,
564564// OR
565565// fs.writeSync(fd, string[, position[, encoding]]);
566566function writeSync ( fd , buffer , offset , length , position ) {
567- validateUint32 ( fd , 'fd' ) ;
567+ validateInt32 ( fd , 'fd' , 0 ) ;
568568 const ctx = { } ;
569569 let result ;
570570 if ( isArrayBufferView ( buffer ) ) {
@@ -661,7 +661,7 @@ function ftruncate(fd, len = 0, callback) {
661661 callback = len ;
662662 len = 0 ;
663663 }
664- validateUint32 ( fd , 'fd' ) ;
664+ validateInt32 ( fd , 'fd' , 0 ) ;
665665 validateInteger ( len , 'len' ) ;
666666 len = Math . max ( 0 , len ) ;
667667 const req = new FSReqCallback ( ) ;
@@ -670,7 +670,7 @@ function ftruncate(fd, len = 0, callback) {
670670}
671671
672672function ftruncateSync ( fd , len = 0 ) {
673- validateUint32 ( fd , 'fd' ) ;
673+ validateInt32 ( fd , 'fd' , 0 ) ;
674674 validateInteger ( len , 'len' ) ;
675675 len = Math . max ( 0 , len ) ;
676676 const ctx = { } ;
@@ -694,28 +694,28 @@ function rmdirSync(path) {
694694}
695695
696696function fdatasync ( fd , callback ) {
697- validateUint32 ( fd , 'fd' ) ;
697+ validateInt32 ( fd , 'fd' , 0 ) ;
698698 const req = new FSReqCallback ( ) ;
699699 req . oncomplete = makeCallback ( callback ) ;
700700 binding . fdatasync ( fd , req ) ;
701701}
702702
703703function fdatasyncSync ( fd ) {
704- validateUint32 ( fd , 'fd' ) ;
704+ validateInt32 ( fd , 'fd' , 0 ) ;
705705 const ctx = { } ;
706706 binding . fdatasync ( fd , undefined , ctx ) ;
707707 handleErrorFromBinding ( ctx ) ;
708708}
709709
710710function fsync ( fd , callback ) {
711- validateUint32 ( fd , 'fd' ) ;
711+ validateInt32 ( fd , 'fd' , 0 ) ;
712712 const req = new FSReqCallback ( ) ;
713713 req . oncomplete = makeCallback ( callback ) ;
714714 binding . fsync ( fd , req ) ;
715715}
716716
717717function fsyncSync ( fd ) {
718- validateUint32 ( fd , 'fd' ) ;
718+ validateInt32 ( fd , 'fd' , 0 ) ;
719719 const ctx = { } ;
720720 binding . fsync ( fd , undefined , ctx ) ;
721721 handleErrorFromBinding ( ctx ) ;
@@ -801,7 +801,7 @@ function fstat(fd, options, callback) {
801801 callback = options ;
802802 options = { } ;
803803 }
804- validateUint32 ( fd , 'fd' ) ;
804+ validateInt32 ( fd , 'fd' , 0 ) ;
805805 const req = new FSReqCallback ( options . bigint ) ;
806806 req . oncomplete = makeStatsCallback ( callback ) ;
807807 binding . fstat ( fd , options . bigint , req ) ;
@@ -832,7 +832,7 @@ function stat(path, options, callback) {
832832}
833833
834834function fstatSync ( fd , options = { } ) {
835- validateUint32 ( fd , 'fd' ) ;
835+ validateInt32 ( fd , 'fd' , 0 ) ;
836836 const ctx = { fd } ;
837837 const stats = binding . fstat ( fd , options . bigint , undefined , ctx ) ;
838838 handleErrorFromBinding ( ctx ) ;
@@ -1065,7 +1065,7 @@ function lchownSync(path, uid, gid) {
10651065}
10661066
10671067function fchown ( fd , uid , gid , callback ) {
1068- validateUint32 ( fd , 'fd' ) ;
1068+ validateInt32 ( fd , 'fd' , 0 ) ;
10691069 validateUint32 ( uid , 'uid' ) ;
10701070 validateUint32 ( gid , 'gid' ) ;
10711071
@@ -1075,7 +1075,7 @@ function fchown(fd, uid, gid, callback) {
10751075}
10761076
10771077function fchownSync ( fd , uid , gid ) {
1078- validateUint32 ( fd , 'fd' ) ;
1078+ validateInt32 ( fd , 'fd' , 0 ) ;
10791079 validateUint32 ( uid , 'uid' ) ;
10801080 validateUint32 ( gid , 'gid' ) ;
10811081
@@ -1126,7 +1126,7 @@ function utimesSync(path, atime, mtime) {
11261126}
11271127
11281128function futimes ( fd , atime , mtime , callback ) {
1129- validateUint32 ( fd , 'fd' ) ;
1129+ validateInt32 ( fd , 'fd' , 0 ) ;
11301130 atime = toUnixTimestamp ( atime , 'atime' ) ;
11311131 mtime = toUnixTimestamp ( mtime , 'mtime' ) ;
11321132 const req = new FSReqCallback ( ) ;
@@ -1135,7 +1135,7 @@ function futimes(fd, atime, mtime, callback) {
11351135}
11361136
11371137function futimesSync ( fd , atime , mtime ) {
1138- validateUint32 ( fd , 'fd' ) ;
1138+ validateInt32 ( fd , 'fd' , 0 ) ;
11391139 atime = toUnixTimestamp ( atime , 'atime' ) ;
11401140 mtime = toUnixTimestamp ( mtime , 'mtime' ) ;
11411141 const ctx = { } ;
0 commit comments