Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp overflow problem #708

Open
rlnsh opened this issue Nov 13, 2024 · 8 comments
Open

Timestamp overflow problem #708

rlnsh opened this issue Nov 13, 2024 · 8 comments

Comments

@rlnsh
Copy link

rlnsh commented Nov 13, 2024

The jsch library will get the modified time of the file will have a timestamp overflow problem, such as after January 19, 2038, will have a negative timestamp time rollback problem. Hope the author can fix the problem next time, tTime field is currently an int and needs to be adjusted to a long type.

@norrisjeremy
Copy link
Contributor

Hi @rlnsh,

Can you please provide more specifics as to what sort of defect you believe is present in JSch?
Your problem report is extremely vague, and I'm not very certain how you would expect us to act upon it.

Thanks,
Jeremy

@rlnsh
Copy link
Author

rlnsh commented Nov 13, 2024

Hi @rlnsh,

Can you please provide more specifics as to what sort of defect you believe is present in JSch? Your problem report is extremely vague, and I'm not very certain how you would expect us to act upon it.

Thanks, Jeremy

In the SftpATTRS class, the mtime and atime fields are int type, and the maximum value is 2147483647. If the server time is changed to January 20, 2038, the obtained mtime and atime are negative values, and the time rollback occurs.

@norrisjeremy
Copy link
Contributor

Hi @rlnsh,

You are aware that this fields are specified in the SFTP standard to which JSch adheres as uint32, and thus this isn't a JSch defect, but rather a defect in the SFTP protocol itself?
You may want to review the SFTP standard?

Thanks,
Jeremy

@rlnsh
Copy link
Author

rlnsh commented Nov 13, 2024

ok, i see, Thanks!

@rlnsh
Copy link
Author

rlnsh commented Nov 13, 2024

The uint32 in the c language in sftp has an unsigned bit and its maximum value is 4294967295. Therefore, java receives packets of the long type.

@norrisjeremy
Copy link
Contributor

The uint32 in the c language in sftp has an unsigned bit and its maximum value is 4294967295. Therefore, java receives packets of the long type.

I'm not sure what point you are attempting to make?
JSch parses this field as 4-byte unsigned integer, per the SFTP standard.

@rlnsh
Copy link
Author

rlnsh commented Nov 14, 2024

If the file date is January 20, 2038, but the mtime obtained by SftpATTRS is incorrect, the timestamp returns a negative number.

@norrisjeremy
Copy link
Contributor

If the file date is January 20, 2038, but the mtime obtained by SftpATTRS is incorrect, the timestamp returns a negative number.

It's the caller's responsibility to correctly interpret the int return value of the SftpATTRS.getMTime() method as being an unsigned integer.
I.e., the caller of the SftpATTRS.getMTime() method should use Integer.toUnsignedLong(), as can be seen in the SftpATTRS.getMtimeString() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants