Commit 67cc0302 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

ntdll: Remove the overly-cautious check which prevented NtSetSystemTime from…

ntdll: Remove the overly-cautious check which prevented NtSetSystemTime from changing the time by more than two minutes. Simplify the returning of different status codes by not playing around with the return value from settimeofday.
parent 54408896
...@@ -62,8 +62,6 @@ static RTL_CRITICAL_SECTION_DEBUG critsect_debug = ...@@ -62,8 +62,6 @@ static RTL_CRITICAL_SECTION_DEBUG critsect_debug =
}; };
static RTL_CRITICAL_SECTION TIME_tz_section = { &critsect_debug, -1, 0, 0, 0, 0 }; static RTL_CRITICAL_SECTION TIME_tz_section = { &critsect_debug, -1, 0, 0, 0, 0 };
#define SETTIME_MAX_ADJUST 120
#define TICKSPERSEC 10000000 #define TICKSPERSEC 10000000
#define TICKSPERMSEC 10000 #define TICKSPERMSEC 10000
#define SECSPERDAY 86400 #define SECSPERDAY 86400
...@@ -898,7 +896,6 @@ NTSTATUS WINAPI NtSetSystemTime(const LARGE_INTEGER *NewTime, LARGE_INTEGER *Old ...@@ -898,7 +896,6 @@ NTSTATUS WINAPI NtSetSystemTime(const LARGE_INTEGER *NewTime, LARGE_INTEGER *Old
time_t tm_t; time_t tm_t;
DWORD sec, oldsec; DWORD sec, oldsec;
LARGE_INTEGER tm; LARGE_INTEGER tm;
int err;
/* Return the old time if necessary */ /* Return the old time if necessary */
if (!OldTime) OldTime = &tm; if (!OldTime) OldTime = &tm;
...@@ -912,30 +909,20 @@ NTSTATUS WINAPI NtSetSystemTime(const LARGE_INTEGER *NewTime, LARGE_INTEGER *Old ...@@ -912,30 +909,20 @@ NTSTATUS WINAPI NtSetSystemTime(const LARGE_INTEGER *NewTime, LARGE_INTEGER *Old
tv.tv_sec = sec; tv.tv_sec = sec;
tv.tv_usec = 0; tv.tv_usec = 0;
/* error and sanity check*/
if(sec == (time_t)-1 || abs((int)(sec-oldsec)) > SETTIME_MAX_ADJUST) {
err = 2;
} else {
#ifdef HAVE_SETTIMEOFDAY #ifdef HAVE_SETTIMEOFDAY
err = settimeofday(&tv, NULL); /* 0 is OK, -1 is error */ if (!settimeofday(&tv, NULL)) /* 0 is OK, -1 is error */
if(err == 0)
return STATUS_SUCCESS; return STATUS_SUCCESS;
#else
err = 1;
#endif
}
tm_t = sec; tm_t = sec;
ERR("Cannot set time to %s Time adjustment %ld %s\n", ERR("Cannot set time to %s, time adjustment %ld: %s\n",
ctime( &tm_t ), ctime(&tm_t), (long)(sec-oldsec), strerror(errno));
(long)(sec-oldsec), if (errno == EPERM)
err == -1 ? "No Permission"
: sec == (time_t)-1 ? "" : "is too large." );
if(err == 2)
return STATUS_INVALID_PARAMETER;
else if(err == -1)
return STATUS_PRIVILEGE_NOT_HELD; return STATUS_PRIVILEGE_NOT_HELD;
else else
return STATUS_INVALID_PARAMETER;
#else
tm_t = sec;
FIXME("setting time to %s not implemented for missing settimeofday\n",
ctime(&tm_t));
return STATUS_NOT_IMPLEMENTED; return STATUS_NOT_IMPLEMENTED;
#endif
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment