diff options
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/rdate.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/util-linux/rdate.c b/util-linux/rdate.c index 66b877e24..14ce591e9 100644 --- a/util-linux/rdate.c +++ b/util-linux/rdate.c | |||
| @@ -41,7 +41,7 @@ static time_t askremotedate(const char *host) | |||
| 41 | uint32_t nett; | 41 | uint32_t nett; |
| 42 | int fd; | 42 | int fd; |
| 43 | 43 | ||
| 44 | /* Add a timeout for dead or inaccessible servers */ | 44 | /* Timeout for dead or inaccessible servers */ |
| 45 | alarm(10); | 45 | alarm(10); |
| 46 | signal(SIGALRM, socket_timeout); | 46 | signal(SIGALRM, socket_timeout); |
| 47 | 47 | ||
| @@ -53,9 +53,8 @@ static time_t askremotedate(const char *host) | |||
| 53 | close(fd); | 53 | close(fd); |
| 54 | 54 | ||
| 55 | /* Convert from network byte order to local byte order. | 55 | /* Convert from network byte order to local byte order. |
| 56 | * RFC 868 time is the number of seconds | 56 | * RFC 868 time is seconds since 1900-01-01 00:00 GMT. |
| 57 | * since 00:00 (midnight) 1 January 1900 GMT | 57 | * RFC 868 time 2,208,988,800 corresponds to 1970-01-01 00:00 GMT. |
| 58 | * the RFC 868 time 2,208,988,800 corresponds to 00:00 1 Jan 1970 GMT | ||
| 59 | * Subtract the RFC 868 time to get Linux epoch. | 58 | * Subtract the RFC 868 time to get Linux epoch. |
| 60 | */ | 59 | */ |
| 61 | nett = ntohl(nett) - RFC_868_BIAS; | 60 | nett = ntohl(nett) - RFC_868_BIAS; |
| @@ -66,7 +65,7 @@ static time_t askremotedate(const char *host) | |||
| 66 | * current time cur = 0x123ffffffff. | 65 | * current time cur = 0x123ffffffff. |
| 67 | * Assuming our time is not some 40 years off, | 66 | * Assuming our time is not some 40 years off, |
| 68 | * remote time must be 0x12400000001. | 67 | * remote time must be 0x12400000001. |
| 69 | * Need to adjust out time by (int32_t)(nett - cur). | 68 | * Need to adjust our time by (int32_t)(nett - cur). |
| 70 | */ | 69 | */ |
| 71 | time_t cur = time(NULL); | 70 | time_t cur = time(NULL); |
| 72 | int32_t adjust = (int32_t)(nett - (uint32_t)cur); | 71 | int32_t adjust = (int32_t)(nett - (uint32_t)cur); |
