mirror of
https://github.com/wiire-a/pixiewps.git
synced 2025-07-26 23:35:03 +02:00
Merge pull request #68 from binarymaster/master
Allow to set seed up to 0x7FFFFFFF
This commit is contained in:
commit
fd6f4a28e2
29
src/utils.h
29
src/utils.h
@ -170,7 +170,6 @@ time_t c_timegm(register struct tm *t) {
|
|||||||
unsigned int get_unix_datetime(char *s, time_t *datetime) {
|
unsigned int get_unix_datetime(char *s, time_t *datetime) {
|
||||||
unsigned int len = strlen(s);
|
unsigned int len = strlen(s);
|
||||||
int month = 0, year;
|
int month = 0, year;
|
||||||
struct tm t;
|
|
||||||
|
|
||||||
if (len == 4) {
|
if (len == 4) {
|
||||||
if (get_int(s, &year))
|
if (get_int(s, &year))
|
||||||
@ -198,23 +197,29 @@ unsigned int get_unix_datetime(char *s, time_t *datetime) {
|
|||||||
|
|
||||||
if (get_int(s_month, &month) || get_int(s_year, &year))
|
if (get_int(s_month, &month) || get_int(s_year, &year))
|
||||||
return 1;
|
return 1;
|
||||||
if (year < 1970 || year > 2038 || month < 1 || month > 12)
|
if (year < 1970 || year > 2038 || month < 1 || month > 12 || (month > 2 && year == 2038))
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
t.tm_sec = 0;
|
if (year == 2038 && month == 2) {
|
||||||
t.tm_min = 0;
|
*datetime = (time_t) 0x7fffffff;
|
||||||
t.tm_hour = 0;
|
}
|
||||||
t.tm_mday = 1;
|
else {
|
||||||
t.tm_mon = month - 1;
|
struct tm t;
|
||||||
t.tm_year = year - 1900;
|
t.tm_sec = 0;
|
||||||
t.tm_isdst = 0;
|
t.tm_min = 0;
|
||||||
*datetime = c_timegm(&t);
|
t.tm_hour = 0;
|
||||||
|
t.tm_mday = 1;
|
||||||
|
t.tm_mon = month - 1;
|
||||||
|
t.tm_year = year - 1900;
|
||||||
|
t.tm_isdst = 0;
|
||||||
|
*datetime = c_timegm(&t);
|
||||||
|
|
||||||
if (*datetime < 0)
|
if (*datetime < 0) /* When time_t is 64 bits this check is pointless */
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user