Print this page
7122 fix negative timestamps with nsec == 0 in nfs4_time_ntov()


 478 {
 479         int64_t sec;
 480         int32_t nsec;
 481 
 482         /*
 483          * Here check that the nfsv4 time is valid for the system.
 484          * nfsv4 time value is a signed 64-bit, and the system time
 485          * may be either int64_t or int32_t (depends on the kernel),
 486          * so if the kernel is 32-bit, the nfsv4 time value may not fit.
 487          */
 488 #ifndef _LP64
 489         if (! NFS4_TIME_OK(ntime->seconds)) {
 490                 return (EOVERFLOW);
 491         }
 492 #endif
 493 
 494         /* Invalid to specify 1 billion (or more) nsecs */
 495         if (ntime->nseconds >= 1000000000)
 496                 return (EINVAL);
 497 
 498         if (ntime->seconds < 0) {
 499                 sec = ntime->seconds + 1;
 500                 nsec = -1000000000 + ntime->nseconds;
 501         } else {
 502                 sec = ntime->seconds;
 503                 nsec = ntime->nseconds;
 504         }
 505 
 506         vatime->tv_sec = sec;
 507         vatime->tv_nsec = nsec;
 508 
 509         return (0);
 510 }
 511 
 512 int
 513 nfs4_time_vton(timestruc_t *vatime, nfstime4 *ntime)
 514 {
 515         int64_t sec;
 516         uint32_t nsec;
 517 
 518         /*




 478 {
 479         int64_t sec;
 480         int32_t nsec;
 481 
 482         /*
 483          * Here check that the nfsv4 time is valid for the system.
 484          * nfsv4 time value is a signed 64-bit, and the system time
 485          * may be either int64_t or int32_t (depends on the kernel),
 486          * so if the kernel is 32-bit, the nfsv4 time value may not fit.
 487          */
 488 #ifndef _LP64
 489         if (! NFS4_TIME_OK(ntime->seconds)) {
 490                 return (EOVERFLOW);
 491         }
 492 #endif
 493 
 494         /* Invalid to specify 1 billion (or more) nsecs */
 495         if (ntime->nseconds >= 1000000000)
 496                 return (EINVAL);
 497 
 498         if (ntime->seconds < 0 && ntime->nseconds != 0) {
 499                 sec = ntime->seconds + 1;
 500                 nsec = -1000000000 + ntime->nseconds;
 501         } else {
 502                 sec = ntime->seconds;
 503                 nsec = ntime->nseconds;
 504         }
 505 
 506         vatime->tv_sec = sec;
 507         vatime->tv_nsec = nsec;
 508 
 509         return (0);
 510 }
 511 
 512 int
 513 nfs4_time_vton(timestruc_t *vatime, nfstime4 *ntime)
 514 {
 515         int64_t sec;
 516         uint32_t nsec;
 517 
 518         /*