diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-12-18 13:37:28 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-12-18 13:37:28 +0800 |
commit | 7deddbaf74047db0e64d07a0798c71592e8aa8d5 (patch) | |
tree | 196b42541dc79cc0eb2dd1c8089d2707e36ecdf0 /mbbsd | |
parent | 16bf63475770e642a94d5d617b000f025846fddf (diff) | |
download | pttbbs-7deddbaf74047db0e64d07a0798c71592e8aa8d5.tar pttbbs-7deddbaf74047db0e64d07a0798c71592e8aa8d5.tar.gz pttbbs-7deddbaf74047db0e64d07a0798c71592e8aa8d5.tar.bz2 pttbbs-7deddbaf74047db0e64d07a0798c71592e8aa8d5.tar.lz pttbbs-7deddbaf74047db0e64d07a0798c71592e8aa8d5.tar.xz pttbbs-7deddbaf74047db0e64d07a0798c71592e8aa8d5.tar.zst pttbbs-7deddbaf74047db0e64d07a0798c71592e8aa8d5.zip |
- fix signed time4_t limitation
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3704 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/stuff.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index b5b18645..9d08e2d2 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -223,7 +223,13 @@ gettime(int line, time4_t dt, const char*head) i=strlen(head); do { getdata_buf(line, i, " ¦è¤¸¦~:", yn, 5, LCECHO); - } while ((endtime.tm_year = atoi(yn) - 1900) < 0 || endtime.tm_year > 200); + } while ((endtime.tm_year = atoi(yn) - 1970) < 0 || endtime.tm_year > 200); + + // current time4_t is signed. + // safe range: 2038(signed)~1970(unsigned) + if (endtime.tm_year > 137) endtime.tm_year = 137; + if (endtime.tm_year < 70) endtime.tm_year = 70; + snprintf(yn, sizeof(yn), "%d", ptime->tm_mon + 1); do { getdata_buf(line, i+15, "¤ë:", yn, 3, LCECHO); |